#include <array>
struct A
{
A(char value, char another);
const std::array<char, 42> something; // how to init?
}
Considered approaches:
- a
const_cast
is always dangerous and often UB - the docs list the only ctor as taking an aggregate parameter - what I want to do is accept some other parameter and initialize the constant
- removing the constness is ... undesirable. The whole semantics are "create this; it will never need to change"
- using
std::string
worries me as inefficient and this is an embedded device std::experimental::make_array
looks promising but not standard yet- an init list in the ctor seems promising but how?
Can it be done and how?