简体   繁体   English

我可以在g ++ 4.4中使用auto吗?

[英]can I use auto with g++ 4.4?

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: 我可以使用g ++ 4.4指定-std = c ++ 0x进行编译,并且初始化列表正确,可以使用它们(在c ++ 98中不能使用),但是在尝试使用auto关键字时仍然会出错:

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. 所以我假设我不能在g ++ 4.4中使用C ++ 11功能。 I have 4.4 because of compatibility with CUDA. 我有4.4,因为与CUDA兼容。

This link shows you the different C++11 features supported by GCC. 该链接向您显示了GCC支持的不同C ++ 11功能。 auto appeared in GCC 4.4. auto出现在GCC 4.4中。

Your real problem is probably that the ranged-based for loop appeared only in GCC 4.6. 您的真正问题可能是基于范围的for循环仅出现在GCC 4.6中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM