0

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?

Elvis Dukaj
  • 7,142
  • 12
  • 43
  • 85
  • 1
    I cannot test it with a MSVC2013 right now, but have you tryied to enclose the initializer list into a parenthesis... you want to call the constructor after all. Demo [here](http://ideone.com/ruCGhB). – PaperBirdMaster Feb 03 '14 at 17:10
  • it works... but why that work on gcc? – Elvis Dukaj Feb 03 '14 at 17:10
  • For the record, the error message in english reads: `error C2661: 'std::vector>::vector' : no overloaded function takes 4 arguments` – Felix Glas Feb 03 '14 at 17:17

1 Answers1

0

Try this:

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

}

Demo here.

PaperBirdMaster
  • 12,806
  • 9
  • 48
  • 94
  • 2
    @elvis.dukaj You are correct; not accepting the syntax in the OP is a bug in Visual C++. – Casey Feb 03 '14 at 17:31