Inside STL: The array -- Raymond Chen
The C++ standard library array is just a C-style array wrapped inside a class so that it behaves like a normal C++ object instead of a wacky thing that undergoes decay.
Inside STL: The array
By Raymond Chen
From the article:
template<typename T, size_t N> class array { T elements[N]; }; template<typename T> class array<T, 0> { };The only weird case is N = 0. You are allowed to create a zero-length
std::array, but C++ does not allow zero-length C-style arrays. The zero-lengthstd::arrayis just an empty class.Visual Studio and the Windows debugger come with a visualizer:
0:000> dx a a : { size=5 } [Type: std::array<int,5>] [<Raw View>] [Type: std::array<int,5>] [0] : 3 [Type: int] [1] : 1 [Type: int] [2] : 4 [Type: int] [3] : 1 [Type: int] [4] : 5 [Type: int]

People often say constexpr all the things. Andreas Fertig shows where we can use dynamic memory at compile time.
Registration is now open for CppCon 2023! The conference starts on October 1 and will be held