我正在使用 Visual Studio 2012,同时尝试使用默认编译器和 Nov CTP 编译器,以下显示了我的问题:
struct doesCompile
{
int mA, mB, mC, mD, mE;
doesCompile(int a, int b, int c, int d, int e) : mA(a), mB(b), mC(c), mD(d), mE(e)
{
}
};
struct doesNotCompile
{
int mA, mB, mC, mD, mE, mF;
doesNotCompile(int a, int b, int c, int d, int e, int f) : mA(a), mB(b), mC(c), mD(d), mE(e), mF(f)
{
}
};
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<doesCompile> goodVec;
goodVec.emplace_back(1, 2, 3, 4, 5);
std::vector<doesNotCompile> badVec;
badVec.emplace_back(1, 2, 3, 4, 5, 6); // error C2660: 'std::vector<_Ty>::emplace_back' : function does not take 6 arguments
return 0;
}
为什么看起来 emplace_back 最多只能有 5 个参数?他们甚至在http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx中说这将需要任意数量的参数..
有没有办法解决这个问题,使用VS2012?