new std::array<int, 10>
Could not find more explicit answer in the standard, but
An array is an aggregate (
[dcl.init.aggr]) that can be list-initialized with up to
Nelements whose types are convertible to
An aggregate is an array or a class (Clause
- no user-provided, explicit, or inherited constructors (
That about covers it. No way an aggregate could allocate memory dynamically (or perhaps, do anything at all at its own during the construction). There's only an implicitly-declared trivial constructor.
Of course, if you
new std::array<...>, you get an array on "the heap".
Some might be more satisfied by what we can get on cppreference:
std::arrayis a container that encapsulates fixed size arrays.
This container is an aggregate type with the same semantics as a struct holding a C-style array
T[N]as its only non-static data member.
std::array was introduced in C++11. Why? For example, to complement
std::vector in some things, like usage in
constexpr functions, where dynamic allocation is not allowed.