I currently try to initialize the following array, Spot is a class that is defined elsewhere:
static const int WIDTH = 7;
static const int HEIGHT = 6;
std::array<std::array<std::unique_ptr<Spot>, WIDTH>, HEIGHT> field;
When trying to initialize it:
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
field.at(i).at(j) = std::make_unique<Spot>(new Spot());
}
}
it states that Spot* cannot be converted to const Spot &, which makes pretty much sense.
Google is not really helpful here, as the questions either deal with
std::unique_ptr<T> [] or
std::uniqe_ptr<std::array<T>> but not with
std::array<std::unique_ptr<T>>
So, how do you achieve that? Is that even a thing? Or are you not supposed to use std::arrays with smart pointers at all?