我正在尝试在 VS 2010 中编译可以在 gcc 中编译和工作的代码,但是在 lambda 表达式上出现了一个奇怪的错误:
std::function<double (size_t level, size_t q)> doLevel = [&](size_t level, size_t q)
{ //line 52
double thisLevelP = density(q, data[level]);
if(level==T-1) return thisLevelP;
if(level==t-1) return thisLevelP*A(q,state)*doLevel(level+1,state);
double continuation = 0.0;
for(size_t i=0; i<Q; ++i)
{
continuation += A(q, i)*doLevel(level+1, i);
}
return thisLevelP*continuation;
};
错误是:
Error 1 error C2086: 'size_t &_T' : redefinition c:\users\ga1009\documents\phd\cpp\pmi\cpp\test\baumiterationtest.cpp 52
Error 2 error C2661: '`anonymous-namespace'::`anonymous-namespace'::<lambda1>::<lambda1>' : no overloaded function takes 8 arguments c:\users\ga1009\documents\phd\cpp\pmi\cpp\test\baumiterationtest.cpp 52
怎么了?