Workaround for error C2536: cannot specify explicit initializer for arrays in Visual Studio 2013

As the comments, you can try this workaround.

class A
{
    A() : m_array ({ 0, 1, 2 }) {}
private:
    std::array<int, 3> m_array;
};

It seems VS2013 made initializer-list for std::array constructor well and you can initialize it in constructor’s intializer. The code that you wrote is valid and both gcc and clang support it. VS2013 lacks.

Leave a Comment