Unions can be templates too.

template<typename From, typename To>
union union_cast {
    From from;
    To   to;
 
    union_cast(From from)
        :from(from) { }
 
    To getTo() const { return to; }
};
And they can have constructors and member functions too. Just nothing that has to do with inheritance (including virtual functions).

You can have lambdas in C++ with GCC and Boost even without C++11 support.

int val = 2;
int nums[] = {1, 2, 3};
int* end = nums + 3;
 
int* iter = std::find_if(nums, end,
    GCC_LAMBDA(const bind val, int num, return bool) {
        return num == val;
    } GCC_LAMBDA_END
);
The GCC lambda function macros are implemented using local functions.
You can read more on this here.

Your C++ code may be much slower in reading lines from stdin than Python by default.

Assume following simple case:
// C++ code
while (std::cin) {
    getline(std::cin, input_line);
    if (!std::cin.eof()) {
        line_count++;
    }
}
# Python code
for line in  sys.stdin:
    count += 1

$ cat test_lines | ./readline_test_cpp
Saw 5570000 lines in 9 seconds.  Crunch speed: 618889

$cat test_lines | ./readline_test.py
Read 5570000 lines in 1 seconds. LPS: 5570000

Reason: by default, std::cin is synchronized with stdio, which causes it to avoid any input buffering. If you add this to the top of your main, you should see much better performance:
std::cin.sync_with_stdio(false);

You can use cling, an interactive interpreter for the C++ language based on clang/LLVM, for quick testing of small code pieces.

[cling]$ #include
[cling]$ using namespace std;
[cling]$ int a[] = {1,2,3};
[cling]$ for (int& x: a){ x += 10; }
[cling]$ for (int& x: a){ cout << x << “,”; }
11,12,13,
It supports both old C++03 and new C++11 standards fine!

Do you know if the following code is valid and, if yes, what will it output?

#include <stdio>
 
int main()
{
  int array[] = { 0, 1, 2 };
  printf("%d %d %d\n", 10, (5, array[1, 2]), 10);
}
(Yeah, an easy one this time, but it’s Friday  :-D).

The next code doesn’t call object’s destructor when exception is thrown if compiled with GCC or MS Visual C++:

#include <iostream>
#include <stdexcept>
 
struct A {
    A () { std::cout << "A" << std::endl; }
    ~A () { std::cout << "~A" << std::endl; }
};
 
void myfunc () {
    A temp;
    throw std::runtime_error("moo");
}
 
int main () {
    myfunc();
}
                                                  

This is caused by lack of matching catch() handler –if you add it destructor will be called properly.
Looking at the C++ standard, section 15.3 [except.handle] point 9, we see:
If no matching handler is found in a program, the function terminate()
(_except.terminate_) is called. Whether or not the stack is unwound
before calling terminate() is implementation-defined.
Both gcc and Visual Studio behave the same in this context, and do not perform full stack unwinding in this case.