lundi 21 décembre 2020

Vector of Objects that have vector of unique pointers

I have a vector ex:TestStructVec of objects for ex:TestStruct, where object contains a vector of unique pointers ex: uptrVec.

struct TestStruct
{
   std::vector<std::unique_ptr<TestClass> uptrVec;
}
std::vector<TestStruct> TestStructVec;


TestStruct ts1;
 ts1.uptrVec.emplace_back(std::make_unique<TestClass>());

Now, when emplace back this object to vector, only in vs2013 , c++11, it fails with attempt to reference the deleted function (assuming its some copy const issue). I

TestStructVec.emplace_back(std::move(ts1));

Pls let me know where im doing it wrong.

NOTE: In VS2015, and Vs2017 it compiles Fine and no error is observed.

Any recommendation is appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire