Is it safe to copy and reset shared_ptr at the same time?
Namely consider the following code
// Main thread (before creating any other threads)
shared_ptr<A> a(new A(1));
// Thread 1
shared_ptr<A> a_copy = a;
// Thread 2
a.reset(new(A(2));
where thread 1 and 2 run in parallel. Can I be sure, that a_copy
will store pointer either to the older A(1)
or to the newer A(2)
shared object?