【发布时间】:2013-03-29 18:08:28
【问题描述】:
我正在使用 tbb::parallel_for 函数,它利用了 lambda。我收到以下代码的语法错误:
void parallel_relax( Class object, std::vector<Vertex *> verList ) {
tbb::parallel_for (blocked_range<int>(0, verList.size()), [=](const blocked_range<Vertex *>& r) {
for(Vertex *vit = r.begin(); vit != r.end(); ++vit) {
Vertex *v = vit;
object.function(v);
}
});
}
语法错误:
syntax error : '['
1>main.cpp(16): error C2143: syntax error : missing ')' before '{'
1>main.cpp(16): error C2143: syntax error : missing ';' before '{'
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.begin' must have class/struct/union
1> type is ''unknown-type''
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.end' must have class/struct/union
1> type is ''unknown-type''
1>main.cpp(20): error C2059: syntax error : ')'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我认为这是编译器的问题。我如何获得 Visual Studio 2010 Express Edition 的 c++11 编译器。请提出建议。
【问题讨论】:
-
第 16 行和第 17 行是什么?
-
"tbb::parallel_for" 是第 16 行,"for(Vertex *vit = r.begin(); vit != r.end(); ++vit)" 是第 17 行跨度>
-
所以我不能使用 C++11,因为我在 Windows 7 上,我只能使用 Visual Studio 2010?顺便说一句...我不想将 Eclipse 与 MinGW G++ 一起使用,因为我觉得它很难看... :(
标签: c++ visual-studio-2010 visual-c++ c++11 tbb