std::array::max_size() returns the maximum number of elements that an array can ever hope to contain. The size of the array is a compile-time constant and part of its type. He can only ever hold just such a number of elements. The number of elements it contains and the number of elements it can contain are the same for std::array .
This particular function does not add much value to std::array , but it exists for compatibility with other containers, which can store a variable number of elements. Consider the case where a function template expects some type of container as an argument. You may be interested to know that the container capacity is maximum, and not std::array or another container.
source share