Thursday, March 8, 2018

c++ - How to add a value to a vector of arrays?

I need to create a vector where each value is in fact four values. So good old Google led me to these pages:




Vector of a Fixed size array



Cant make a vector of fixed size arrays?



Vector of vectors, reserve



From these threads I'm led to believe it is optimal with the following syntax:



std::vector> arrayVector;



That part seems to work, but now I'd like to add my first row of values:



arrayVector.push_back({ 0, 1, 2, 3 });


And that part does not compile:





Severity Code Description Project File Line Suppression State
Error (active) no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=std::array, _Alloc=std::allocator>]" matches the argument list




I've also tried creating the int array as a separate variable and passing that variable to the push_back, also with the same result.



I'm using Microsoft Visual Studio Community 2015, I'm not one to normally choose C++, so I might be missing something obvious. Thanks in advance.

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...