can I use auto with g++ 4.4?

2019-07-13 18:41发布

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条回答
家丑人穷心不美
2楼-- · 2019-07-13 19:09

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.

查看更多
登录 后发表回答