2010-05-11 21:42:16 +02:00
|
|
|
#ifndef MOVEONLY_H
|
|
|
|
#define MOVEONLY_H
|
|
|
|
|
|
|
|
#ifdef _LIBCPP_MOVE
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
class MoveOnly
|
|
|
|
{
|
|
|
|
MoveOnly(const MoveOnly&);
|
|
|
|
MoveOnly& operator=(const 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;}
|
|
|
|
|
|
|
|
int get() const {return data_;}
|
|
|
|
|
2010-08-22 02:59:46 +02:00
|
|
|
bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
|
|
|
|
bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
|
2010-05-11 21:42:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct hash<MoveOnly>
|
|
|
|
: public std::unary_function<MoveOnly, std::size_t>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const MoveOnly& x) const {return x.get();}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-22 02:59:46 +02:00
|
|
|
#endif // _LIBCPP_MOVE
|
2010-05-11 21:42:16 +02:00
|
|
|
|
2010-08-22 02:59:46 +02:00
|
|
|
#endif // MOVEONLY_H
|