Not an actual problem but rather a fashion crisis..
vector<array<unsigned int, 3>> tri;
tri.push_back(array<unsigned int, 3> {0, 0, 0});
gives me a syntax error. Is there any way to initialize a std array with values into a vector in one line?
Not an actual problem but rather a fashion crisis..
vector<array<unsigned int, 3>> tri;
tri.push_back(array<unsigned int, 3> {0, 0, 0});
gives me a syntax error. Is there any way to initialize a std array with values into a vector in one line?
The first rule of std::array
is: when in doubt, add more braces. That's because you're actually initializing the raw array subobject of the std::array
.
tri.push_back(array<unsigned int, 3> {{0, 0, 0}});
Both GCC and Clang accept this statement.
vs10 still wont accept it :/
And this is why it's important to always provide complete information in your questions.
Visual Studio 2010 does not implement uniform initialization (and that is uniform initialization, not merely aggregate initialization). It's not a C++11-compliant compiler; it just has a few C++11 features.