Auto add '-std=c++11' to the compiler flags

'-std=c++11' enables C++11 support on, at least, clang++ and g++. Other
compilers may need diffent flags.
Minor code reorganization. No functional changes