allow OwningPtr to be copy constructed if null, which is required to
[oota-llvm.git] / include / llvm / ADT / OwningPtr.h
index 6d9c30597789365a6fd539b4c2ab3c2eb2d3e14a..e82ebc7b049c848381eafae2192859dfffdea6d9 100644 (file)
@@ -25,12 +25,15 @@ namespace llvm {
 /// pointee object can be taken away from OwningPtr by using the take method.
 template<class T>
 class OwningPtr {
-  OwningPtr(OwningPtr const &);             // DO NOT IMPLEMENT
-  OwningPtr &operator=(OwningPtr const &);  // DO NOT IMPLEMENT
+  OwningPtr &operator=(const OwningPtr &);  // DO NOT IMPLEMENT
   T *Ptr;
 public:
   explicit OwningPtr(T *P = 0) : Ptr(P) {}
 
+  OwningPtr(const OwningPtr &RHS) : Ptr(0) {
+    assert(RHS.Ptr == 0 && "Only null OwningPtr's are copyable!");
+  }
+
   ~OwningPtr() {
     delete Ptr;
   }