Is shared_ptr swap thread safe? Is shared_ptr swap thread safe? multithreading multithreading

Is shared_ptr swap thread safe?


No, swap isn't thread safe, but there's another function that is:

atomic_store(&global, sp);

There's also atomic_exchange which returns the old value, if you need that.