问题
I can specify -std=c++0x for compilation with my g++ 4.4, and initializer lists are correct, I may use them (in c++98 I can't) but still get errors when try use auto keyword:
std::list< std::vector<int> > li2;
li2.push_back({1, 2, 3}); //push_back vector
li2.push_back({4, 2, 6}); //again, vector implicitly
for (auto& vv : li2) {
for (auto &i : v)
printf("element: %d\n", 8);
}
so I assume I can't use C++11 functionallities with g++4.4. I have 4.4 because of compatibility with CUDA.
回答1:
This link shows you the different C++11 features supported by GCC. auto
appeared in GCC 4.4.
Your real problem is probably that the ranged-based for
loop appeared only in GCC 4.6.
来源:https://stackoverflow.com/questions/16225550/can-i-use-auto-with-g-4-4