首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在STLport库中使用const

如何在STLport库中使用const
EN

Stack Overflow用户
提问于 2013-08-15 11:13:56
回答 1查看 286关注 0票数 1

我试着编译基本示例:

代码语言:javascript
复制
#include <vector>
int main ()
{
    std::vector<int> testV;
    for (const auto& test : testV) 
    {   }
    return 0;
}

我收到了错误:

test.cpp: In function 'int main()':

test.cpp:5:29: error: 'begin' was not declared in this scope

test.cpp:5:29: error: 'end' was not declared in this scope

test.cpp:5:29: error: unable to deduce 'const auto&' from '<expression error>'

STLport支持const auto吗?

GCC 4.6编辑:我正在使用编辑

有4.7或更多都没问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-15 11:24:24

gcc 4.6是在2011年春天发布的,在大多数C++11功能中也不是没有bug。Moroever,大约在同一时间范围内的ADL查找规则也进行了修改(注意,这是在2011年夏天正式批准C++11标准之前)。有关更多详细信息,请参阅this Q&A。这可能不值得调试,推荐的操作方法是升级到最新版本的gcc (4.7,最好是4.8)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18251552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档