allow OwningPtr to be copy constructed if null, which is required to

make them be a valuetype in a DenseMap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2012-01-23 08:19:57 +00:00
parent 7925e2555d
commit cef3925698

View 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;
}