问题
I've the following code that doesn't compile with vc++ 2013. Is it a compiler bug?
class Test
{
public:
Test() :
mTestBuff{ 1, 2, 3, 4 }
{
}
private:
const vector< int > mTestBuff;
};
error C2661: 'std::vector<int,std::allocator<_Ty>>::vector' : no overloaded function takes 4 arguments
This compile fine with GCC 4.8 and MinGW. What can I done to remove the compile error?
回答1:
Try this:
Test() :
mTestBuff({ 1, 2, 3, 4 })
{
}
Demo here.
来源:https://stackoverflow.com/questions/21533191/vc-2013-initializer-list-issue