Discussion on C, C++ and C++11 at the COJ. This is the place to clear your doubts about these languages, and to share with the community the new things you learn about them.
- Posts: 3
- Joined: 7 years ago
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 instead.
- Type deduction: Using auto to let the compiler deduce the type of an expression. Instead of typing
we can now say
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
std::map<std::string, int> m;
for (std::map<std::string, int>::iterator 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.
I propose that the compiler be upgraded so that these features are available for use.
- Posts: 37
- Joined: 7 years ago
- Location: Guadalajara, Mexico
Thank you very much for your suggestion! Indeed, C++11 is a very important improvement to the language. However, enabling it on the site might not be a very god idea... remember that the COJ is primarily a training platform for the ACM-ICPC, and if our contestants grow used to the new features of the language, and on the contest they are suddenly deprived of them, this could lead them to waste precious minutes (and ask anyone who have lost the first place by a minute or two if time is of any value...). It could even lead to a submission being judged as compilation error (with the accompanying 20-minute penalty)!! However, we will be waiting for the time when the competition upgrades its official compilers (in fact, this is a very good topic to propose during these World Finals), and when that happens we will upgrade.
(btw, aren't you supposed to be in prison? I thought Tulkas had imprisoned you 'till the end of the world... oh well nevermind