std::array
is, by design, an aggregate, so has no user-declared constructors.
As you say, you could use fill
after default constructing. Since it’s an aggregate, default construction won’t zero the memory, but will leave it uninitialised (if the contained type is trivially initialisable).
More Related Contents:
- std::array vs array performance
- Passing a std::array of unknown size to a function
- Initializing an std::array of non-default-constructible elements?
- How can you iterate over the elements of an std::tuple?
- Implementation C++14 make_integer_sequence
- Range based loop: get item by value or reference to const?
- Does C++ support Variable Length Arrays?
- How is Meyers’ implementation of a Singleton actually a Singleton
- Should the trailing return type syntax style become the default for new C++11 programs? [closed]
- How to automatically convert strongly typed enum into int?
- Why use non-member begin and end functions in C++11?
- How to implement multithread safe singleton in C++11 without using
- Replacement for deprecated register keyword C++ 11
- What is the meaning of “… …” token? i.e. double ellipsis operator on parameter pack
- non-class rvalues always have cv-unqualified types
- Is this C++11 regex error me or the compiler?
- Why are lambda expressions not allowed in an unevaluated operands but allowed in the unevaluated portions of constant expressions?
- What is the reason for not being able to deduce array size from initializer-string in member variable?
- Is std::abs(0u) ill-formed?
- Compile time triggered range check for std::vector
- Static constexpr odr-used or not?
- What is the use of 0-length array (or std::array)?
- May std::vector make use of small buffer optimization?
- Is there a compiler bug exposed by my implementation of an is_complete type trait?
- Is a constexpr array necessarily odr-used when subscripted?
- When is a const reference better than pass-by-value in C++11?
- Range-based for with brace-initializer over non-const values?
- Why aren’t there compiler-generated swap() methods in C++0x?
- std::enable_if : parameter vs template parameter
- Why must an enumeration’s size be provided when it is forward declared?