Top "Stdvector" questions

std::vector is a contiguous sequence container in the C++ standard library.

What is better: reserve vector capacity, preallocate to size or push back in loop?

I have a function that takes a pointer to char array and segment size as input arguments and calls another …

c++ stdvector
How to cheaply assign C-style array to std::vector?

Currently I do the following: // float *c_array = new float[1024]; void Foo::foo(float *c_array, size_t c_array_…

c++ arrays stl vector stdvector
Select specific elements from a vector

I have a vector v1, and a boolean vector v2 of the same size. I want to delete from v1 …

c++ c++11 stdvector
Vector of std::function with different signatures

I have a number of callback functions with different signatures. Ideally, I would like to put these in a vector …

c++ c++11 stdvector std-function
Overhead to using std::vector?

I know that manual dynamic memory allocation is a bad idea in general, but is it sometimes a better solution …

c++ stdvector dynamic-memory-allocation
What's the "correct" way to pass an empty vector to an object?

I am working on a fairly large C++ project which unfortunately doesn't really use C++ to its full potential. Large …

c++ stl stdvector assignment-operator pass-by-const-reference
How do I convert an armadillo matrix to a vector of vectors?

I created an armadillo c++ matrix as follows: arma::mat A; A.zeros(3,4); I want to convert it to a …

c++ arrays stdvector armadillo
Should I always call vector clear() at the end of the function?

I have some simple function that uses vector like this (pseudo code): void someFunc(void) { std::vector<std::string&…

c++ vector stl stdvector
"static const int" causes linking error (undefined-reference)

I am baffled by the linker error when using the following code: // static_const.cpp -- complete code #include <…

c++ gcc static constants stdvector