Passing a std::array of unknown size to a function

Is there a simple way to make this work, as one would with plain C-style arrays? No. You really cannot do that unless you make your function a function template (or use another sort of container, like an std::vector, as suggested in the comments to the question): template<std::size_t SIZE> void mulArray(std::array<int, SIZE>& arr, const int … Read more

Default initialization of std::array?

By definition, default initialization is the initialization that occurs when no other initialization is specified; the C++ language guarantees you that any object for which you do not provide an explicit initializer will be default initialized (C++11 ยง8.5/11). That includes objects of type std::array<T, N> and T[N]. Be aware that there are types for which … Read more

std::array vs array performance

What are the advantages of using std::array over usual ones? It has friendly value semantics, so that it can be passed to or returned from functions by value. Its interface makes it more convenient to find the size, and use with STL-style iterator-based algorithms. Is it more performant ? It should be exactly the same. … Read more