tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / libc++ / dist / libcxx / test / containers / MoveOnly.h
blobcbf80201abba81a433a1e83b9fbb8c391afd7d9b
1 #ifndef MOVEONLY_H
2 #define MOVEONLY_H
4 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
6 #include <cstddef>
7 #include <functional>
9 class MoveOnly
11 MoveOnly(const MoveOnly&);
12 MoveOnly& operator=(const MoveOnly&);
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;}
22 int get() const {return data_;}
24 bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
25 bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
28 namespace std {
30 template <>
31 struct hash<MoveOnly>
32 : public std::unary_function<MoveOnly, std::size_t>
34 std::size_t operator()(const MoveOnly& x) const {return x.get();}
39 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
41 #endif // MOVEONLY_H