[PATCH] Add some extra checks to the MoveOnly test class to ensure it is not constructed or assigned from in a moved-from state.

David Blaikie dblaikie at gmail.com
Sat Aug 9 15:44:53 PDT 2014


Closed by commit rL215301 (authored by @dblaikie).

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D4095

Files:
  libcxx/trunk/test/containers/MoveOnly.h

Index: libcxx/trunk/test/containers/MoveOnly.h
===================================================================
--- libcxx/trunk/test/containers/MoveOnly.h
+++ libcxx/trunk/test/containers/MoveOnly.h
@@ -22,11 +22,17 @@
 
     int data_;
 public:
-    MoveOnly(int data = 1) : data_(data) {}
-    MoveOnly(MoveOnly&& x)
-        : data_(x.data_) {x.data_ = 0;}
-    MoveOnly& operator=(MoveOnly&& x)
-        {data_ = x.data_; x.data_ = 0; return *this;}
+    MoveOnly(int data = 0) : data_(data) { assert(data != -1); }
+    MoveOnly(MoveOnly &&x) : data_(x.data_) {
+        assert(x.data_ != -1);
+        x.data_ = -1;
+    }
+    MoveOnly &operator=(MoveOnly &&x) {
+        assert(x.data_ != -1);
+        data_ = x.data_;
+        x.data_ = -1;
+        return *this;
+    }
 
     int get() const {return data_;}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4095.12328.patch
Type: text/x-patch
Size: 826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140809/1648df5a/attachment.bin>


More information about the cfe-commits mailing list