I have a class foo
, with a member bar
of type std::shared_ptr<int>
:
class foo
{
std::shared_ptr<int> bar;
/*other stuff here*/
};
In that class I want to assign a new int
to bar
. But I can't write bar = new int();
as the pointer does not have a public assignment operator.
How should I do this? I could std::move
or std::swap
but neither of those seem right.
Aucun commentaire:
Enregistrer un commentaire