Is ReferenceCountedObjectPtr <> assignment atomic?



struct Obj : public ReferenceCountedObject {
  typedef ReferenceCountedObjectPtr <Obj> Ptr;

Obj::Ptr ptr = new Obj;

void thread1 ()
  ptr = new Obj;

Ptr  thread2 ()
  return ptr;

Is the assignment in thread1 atomic? By this, I mean will thread2 always either get the old Obj or the new Obj, with no leaks and no exceptions?


Well, that’s the idea!