The case for a C++11-conforming compiler
Posted: Thu Nov 22, 2012 5:42 pm
The compiler used for compiling the solutions written in C++ should be upgraded so that it conforms to the latest standard of the language, i.e. get rid of g++ 4.4, or at least turn on the flag -std=c++0x. This isn't yet another "Let's use the latest version!" thing... enabling access to C++11 features does provide a huge boost for C++ programmers in a programming contest environment. These are the ones that almost immediately pop up:
- Right-angle brackets: Goodbye to those annoying spaces between two right-angle brackets: Go for
Code: Select all
std::vector<std::vector<int> > v;instead.Code: Select all
std::vector<std::vector<int>> v;
- Type deduction: Using auto to let the compiler deduce the type of an expression. Instead of typing
we can now say
Code: Select all
std::map<std::string, int> m; for (std::map<std::string, int>::iterator it = m.begin(); ...)Needless to say, that saves a lot of typing. (Yes, g++ does support the __typeof extension, but it's... well, an extension.)Code: Select all
for (auto it = m.begin(); ...)
- Unordered versions of std::set and std::map: The headers <unordered_set> and <unordered_map> provide access to unordered versions of sets and maps, which are amazingly fast given that they don't keep their elements in order.