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?

有帮助吗?

解决方案

Try this:

Test() :
    mTestBuff({ 1, 2, 3, 4 })
{

}

Demo here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top