diff --git a/simgear/structure/SGSharedPtr.hxx b/simgear/structure/SGSharedPtr.hxx index 181dcbb6..ce242f05 100644 --- a/simgear/structure/SGSharedPtr.hxx +++ b/simgear/structure/SGSharedPtr.hxx @@ -67,10 +67,19 @@ public: ~SGSharedPtr(void) { reset(); } - // This handles copy assignment using the copy-and-swap idiom, and also move - // assignment thanks to the move construtor. - SGSharedPtr& operator=(SGSharedPtr p) - { swap(p); return *this; } + SGSharedPtr& operator=(const SGSharedPtr& p) + { reset(p.get()); return *this; } + + SGSharedPtr& operator=(SGSharedPtr&& p) + { // Whether self-move is to be supported at all is controversial, let's + // take the conservative approach for now + if (this != &p) { + swap(p); + p.reset(); + } + return *this; + } + template SGSharedPtr& operator=(const SGSharedPtr& p) { reset(p.get()); return *this; }