From 5eb396a8e6d399b105768a1102776c20349ab9e0 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 9 Aug 2014 22:35:47 +0000 Subject: [PATCH] Add some extra checks to the MoveOnly test class to ensure it is not constructed or assigned from in a moved-from state. Some tests were constructing it with 0, so use -1 as the invalid state instead. Reviewers: Marshall Clow Differential Revision: http://reviews.llvm.org/D4095 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215301 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/containers/MoveOnly.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/containers/MoveOnly.h b/test/containers/MoveOnly.h index e4d9f649..96eef959 100644 --- a/test/containers/MoveOnly.h +++ b/test/containers/MoveOnly.h @@ -22,11 +22,17 @@ class MoveOnly 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_;}