summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-01-05 19:32:41 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-01-05 19:32:41 +0000
commitafc9ff99ec1a732f77e4af4a15680fac60697c93 (patch)
tree246bbd372a6ba94c5d3632aa71f0efbbd866c62b /libcxx/test/support
parent7d5de9a1ee5b38da43cbfca586d31b24e94c8ed1 (diff)
downloadbcm5719-llvm-afc9ff99ec1a732f77e4af4a15680fac60697c93.tar.gz
bcm5719-llvm-afc9ff99ec1a732f77e4af4a15680fac60697c93.zip
First half of LWG#2354: 'Unnecessary copying when inserting into maps with braced-init syntax'
llvm-svn: 256859
Diffstat (limited to 'libcxx/test/support')
-rw-r--r--libcxx/test/support/MoveOnly.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/libcxx/test/support/MoveOnly.h b/libcxx/test/support/MoveOnly.h
index e4d9f649560..b9653516cfd 100644
--- a/libcxx/test/support/MoveOnly.h
+++ b/libcxx/test/support/MoveOnly.h
@@ -17,6 +17,7 @@
class MoveOnly
{
+ friend class MoveOnly2;
MoveOnly(const MoveOnly&);
MoveOnly& operator=(const MoveOnly&);
@@ -34,6 +35,29 @@ public:
bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
};
+class MoveOnly2
+{
+ MoveOnly2(const MoveOnly&);
+ MoveOnly2& operator=(const MoveOnly2&);
+
+ int data_;
+public:
+ MoveOnly2(int data = 1) : data_(data) {}
+ MoveOnly2(MoveOnly2&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly2& operator=(MoveOnly2&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+ MoveOnly2(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly2& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+
+ bool operator==(const MoveOnly2& x) const {return data_ == x.data_;}
+ bool operator< (const MoveOnly2& x) const {return data_ < x.data_;}
+};
+
namespace std {
template <>
@@ -43,6 +67,12 @@ struct hash<MoveOnly>
std::size_t operator()(const MoveOnly& x) const {return x.get();}
};
+template <>
+struct hash<MoveOnly2>
+ : public std::unary_function<MoveOnly, std::size_t>
+{
+ std::size_t operator()(const MoveOnly2& x) const {return x.get();}
+};
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
OpenPOWER on IntegriCloud