mardi 29 novembre 2016

unique_ptr with vector: error: call to implicitly-deleted copy constructor of XXX

I want to manage a two dimensional array as below:

std::vector<std::unique_ptr<int []>> vec(5, nullptr);
vec[0] = std::make_unique<int []>(3);
vec[1] = std::make_unique<int []>(4);
...

However I get an error:

error: call to implicitly-deleted copy constructor of 'std::__1::unique_ptr< int [], std::__1::default_delete< int []> >'

Aucun commentaire:

Enregistrer un commentaire