Suppose I have a method that defines a shared_ptr
. After the method finishes, the shared_ptr
will also be deleted. In the interim I have another member that uses that shared_ptr
. So I would like to extend the lifetime of the shared_ptr
past the initial method.
void initial_method(int input)
{
std::shared_ptr<int> a { std::make_shared<int>(input) };
some_delayed_method(a);
}
Is it possible to manually increase the reference count of a by one in this example?
some_delayed_method()
is like a detachment and is referring to a
at a time after the initial_method()
has returned.