[llvm-commits] [llvm] r166242 - /llvm/trunk/include/llvm/ADT/OwningPtr.h
Jordan Rose
jordan_rose at apple.com
Thu Oct 18 15:22:58 PDT 2012
Author: jrose
Date: Thu Oct 18 17:22:58 2012
New Revision: 166242
URL: http://llvm.org/viewvc/llvm-project?rev=166242&view=rev
Log:
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.
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=166242&r1=166241&r2=166242&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/OwningPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/OwningPtr.h Thu Oct 18 17:22:58 2012
@@ -32,6 +32,15 @@
public:
explicit OwningPtr(T *P = 0) : Ptr(P) {}
+#if LLVM_USE_RVALUE_REFERENCES
+ OwningPtr(OwningPtr &&Other) : Ptr(Other.take()) {}
+
+ OwningPtr &operator=(OwningPtr &&Other) {
+ reset(Other.take());
+ return *this;
+ }
+#endif
+
~OwningPtr() {
delete Ptr;
}
@@ -86,6 +95,15 @@
public:
explicit OwningArrayPtr(T *P = 0) : Ptr(P) {}
+#if LLVM_USE_RVALUE_REFERENCES
+ OwningArrayPtr(OwningArrayPtr &&Other) : Ptr(Other.take()) {}
+
+ OwningArrayPtr &operator=(OwningArrayPtr &&Other) {
+ reset(Other.take());
+ return *this;
+ }
+#endif
+
~OwningArrayPtr() {
delete [] Ptr;
}
More information about the llvm-commits
mailing list