llvm.org GIT mirror llvm / e19f112
Add move constructors for OwningPtr and OwningArrayPtr. While LLVM itself is still C++03, there's no reason why tools built on top of it can't use C++11 features. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166242 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rose 7 years ago
1 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3030 T *Ptr;
3131 public:
3232 explicit OwningPtr(T *P = 0) : Ptr(P) {}
33
34 #if LLVM_USE_RVALUE_REFERENCES
35 OwningPtr(OwningPtr &&Other) : Ptr(Other.take()) {}
36
37 OwningPtr &operator=(OwningPtr &&Other) {
38 reset(Other.take());
39 return *this;
40 }
41 #endif
3342
3443 ~OwningPtr() {
3544 delete Ptr;
8594 public:
8695 explicit OwningArrayPtr(T *P = 0) : Ptr(P) {}
8796
97 #if LLVM_USE_RVALUE_REFERENCES
98 OwningArrayPtr(OwningArrayPtr &&Other) : Ptr(Other.take()) {}
99
100 OwningArrayPtr &operator=(OwningArrayPtr &&Other) {
101 reset(Other.take());
102 return *this;
103 }
104 #endif
105
88106 ~OwningArrayPtr() {
89107 delete [] Ptr;
90108 }