[llvm-commits] [llvm] r148688 - /llvm/trunk/include/llvm/ADT/OwningPtr.h

Chris Lattner sabre at nondot.org
Mon Jan 23 00:19:57 PST 2012


Author: lattner
Date: Mon Jan 23 02:19:57 2012
New Revision: 148688

URL: http://llvm.org/viewvc/llvm-project?rev=148688&view=rev
Log:
allow OwningPtr to be copy constructed if null, which is required to
make them be a valuetype in a DenseMap.

Modified:
    llvm/trunk/include/llvm/ADT/OwningPtr.h

Modified: llvm/trunk/include/llvm/ADT/OwningPtr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/OwningPtr.h?rev=148688&r1=148687&r2=148688&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/OwningPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/OwningPtr.h Mon Jan 23 02:19:57 2012
@@ -25,12 +25,15 @@
 /// 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;
   }





More information about the llvm-commits mailing list