我试着编译基本示例:
#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或更多都没问题。
发布于 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)。
https://stackoverflow.com/questions/18251552
复制相似问题