Remove building with NOCRYPTO option
[minix.git] / external / bsd / libc++ / dist / libcxx / test / support / MoveOnly.h
blobe4d9f649560235e7836e68534372115686180111
1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef MOVEONLY_H
11 #define MOVEONLY_H
13 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
15 #include <cstddef>
16 #include <functional>
18 class MoveOnly
20 MoveOnly(const MoveOnly&);
21 MoveOnly& operator=(const MoveOnly&);
23 int data_;
24 public:
25 MoveOnly(int data = 1) : data_(data) {}
26 MoveOnly(MoveOnly&& x)
27 : data_(x.data_) {x.data_ = 0;}
28 MoveOnly& operator=(MoveOnly&& x)
29 {data_ = x.data_; x.data_ = 0; return *this;}
31 int get() const {return data_;}
33 bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
34 bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
37 namespace std {
39 template <>
40 struct hash<MoveOnly>
41 : public std::unary_function<MoveOnly, std::size_t>
43 std::size_t operator()(const MoveOnly& x) const {return x.get();}
48 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
50 #endif // MOVEONLY_H