cbf80201abba81a433a1e83b9fbb8c391afd7d9b
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / containers / MoveOnly.h
1 #ifndef MOVEONLY_H
2 #define MOVEONLY_H
3
4 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
5
6 #include <cstddef>
7 #include <functional>
8
9 class MoveOnly
10 {
11     MoveOnly(const MoveOnly&);
12     MoveOnly& operator=(const MoveOnly&);
13
14     int data_;
15 public:
16     MoveOnly(int data = 1) : data_(data) {}
17     MoveOnly(MoveOnly&& x)
18         : data_(x.data_) {x.data_ = 0;}
19     MoveOnly& operator=(MoveOnly&& x)
20         {data_ = x.data_; x.data_ = 0; return *this;}
21
22     int get() const {return data_;}
23
24     bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
25     bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}
26 };
27
28 namespace std {
29
30 template <>
31 struct hash<MoveOnly>
32     : public std::unary_function<MoveOnly, std::size_t>
33 {
34     std::size_t operator()(const MoveOnly& x) const {return x.get();}
35 };
36
37 }
38
39 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
40
41 #endif  // MOVEONLY_H