So let's assume I have the following class
class NoDefaultConstructor {
NoDefaultConstructor() = delete;
...
};
And I have another class which has an array of type NoDefaultConstructor and other members
class Wrapper {
std::array<NoDefaultConstructor, 2> arr;
...
};
How can I initialize the array in the constructor for Wrapper (maybe in the initializer list using an std::intializer_list)?
More specifically, is the only way I can pass on arguments to the array constructor in the initializer list for Wrapper to have a construct similar to the following? I was thinking of doing this because the size of the array might change in the future.
template <typename... Values>
Wrapper(Values&&... values) : arr{std::forward<Values>(values)...} {}
std::unique_ptr<NoDefaultConstructor>instances in the array instead of justNoDefaultConstructor.std::vectorinstead in that case