I have a function who return an auto_ptr to me and i wish to assign this pointer to a unique_ptr in my class member variable.
Is the above correct? So now there are two pointers, testPtr and p_testUnique, both pointing to the same data returned from GetTest?Code:class Data { .... void Run(); private: std::unique_ptr<Test> p_testUnique; } void Data::Run() { std::auto_ptr<Test> testPtr = GetTest(); std::unique_ptr testPtrUnique(testPtr .get()); p_testUnique = std::move(testPtrUnique); }




Reply With Quote