Does someone know the way to define constant-sized vector?
For example, instead of defining
std::vector
it will be
This ----> std::vector<10, int> is invalid and causes error. But the new C++ standard has introduced a new class; the std::array. You can declare an array like this:
std::array arr; // declares a new array that holds 5 ints
std::array arr2(arr); // arr2 is equal to arr
std::array arr3 = {1, 2, 3, 4, 5}; // arr3 holds 1, 2, 3, 4, 5
The std::array has constant size and supports iterator/const_iterator/reverse_iterator/const_reverse_iterator. You can find more about this class at http://cplusplus.com/reference/stl/array/.