I am wondering if it's possible to initialize a std::array
of objects with an implicitly deleted default constructor, without knowing a priori the size of the array because it's a template argument and so having lost the possibility of using an initializer list. Code follows, it breaks with a "call to implicitly-deleted default constructor of std::array<A, 3UL>
"
struct A {
A (int b, int c) : mb(b), mc(c) { }
int mb;
int mc;
};
template <size_t NR_A>
struct B {
B (int b, int c) :
// <- how to initialize mAs here?
{ }
std::array<A, NR_A> mAs;
};
B<3> inst(1,1);
edit: I'd like to initialize all the A
's of mAs
to A{1,1}