Thanks for all the answers in the comments.
Then I checked back the C ++ 98 and 03 standard, and yes, 8.5.4 is definitely a new second in C ++ 11! This is why it is not fully supported by all compilers.
After adding the -std = C ++ 0x flag with gcc 4.6.1 now it compiles fine.
Adding test code for anyone who might need a link:
#include <map> #include <string> #include <initializer_list> #include <iostream> using namespace std; int main() { std::map<std::string,int> collection = {{"bear",4}, {"cassowary",2}, {"tiger",7}}; for(auto it: collection) std::cout << it.first << " has value " << it.second << std::endl; return 0; }
Gobst source share