user2311165
user2311165

Reputation: 63

c++11 std array - differences between gcc and visual studio

I have a problem with this part of code:

typedef std::array<u32, 3> my_array;

void foo()
{
    my_array a1{{1, 2, 3}};
    a1 = {{1, 2, 3}}; // PROBLEM - does not work;

    my_array a2{{3, 2, 1}};
    a1 = a2;
}

GCC 4.7 compiles this code as well, but Visual studio with cl from November 2012 fails with:

 error C2679: binary '=' : no operator found which takes a right-hand
 operand of type 'initializer-list' (or there is no acceptable
 conversion) 1>        C:\Program Files (x86)\Microsoft Visual Studio
 11.0\VC\INCLUDE\array(211): could be 'std::array<u32,3> &std::array<u32,3>::operator =(const std::array<u32,3> &)' 1>       
 while trying to match the argument list '(my_array, initializer-list)'

Is this syntax correct and agreed with c++11 standard? I cannot find any informations about this and do not know which compiler I should blame. Thanks in advance for help.

Best regards.

Upvotes: 1

Views: 1666

Answers (1)

bash.d
bash.d

Reputation: 13207

As I stated, VS2012 is a little lame and has some difficulties with C++11, if you want a list, look here.

Upvotes: 1

Related Questions