I have a problem with this code:
A* a = createAnAObject().get();
where createAnAObject() returns unique_ptr
the problem is that I have to do this:
x.setA(a);
and the X
object must have ownership of the A
object, however, as I understand it, unique_ptr::get()
creates a temporary object, which goes out of scope the next line and calls the destructor, deleting my A
object?
What should I do? I cannot change the interface to the X
object.
Aucun commentaire:
Enregistrer un commentaire