Cannot add a unique_ptr to a std::array

Viewed 450

After searching through books and online until the onset of a big pain between my ears, I cannot figure out how to add a std::unique_ptr to a std::array.

The following is a class member:

std::array<std::unique_ptr<Media>, MAX_ELMS_NUM> m_collection;

In the .cpp file I am trying to add a new media pointer stuffed in a std::unique_ptr to the array:

Media* newMedia = CreateNewMedia(Media info stuff);
unique_ptr<Media> np(newMedia);
m_collection[0] = np;

Everything compiles except for the last line.

3 Answers
Related