Question

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?

Was it helpful?

Solution

Try this:

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

}

Demo here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top