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 //===----------------------------------------------------------------------===// 9 10 #ifndef EMPLACEABLE_H 11 #define EMPLACEABLE_H 12 13 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14 15 class Emplaceable 16 { 17 Emplaceable(const Emplaceable&); 18 Emplaceable& operator=(const Emplaceable&); 19 20 int int_; 21 double double_; 22 public: 23 Emplaceable() : int_(0), double_(0) {} 24 Emplaceable(int i, double d) : int_(i), double_(d) {} 25 Emplaceable(Emplaceable&& x) 26 : int_(x.int_), double_(x.double_) 27 {x.int_ = 0; x.double_ = 0;} 28 Emplaceable& operator=(Emplaceable&& x) 29 {int_ = x.int_; x.int_ = 0; 30 double_ = x.double_; x.double_ = 0; 31 return *this;} 32 33 bool operator==(const Emplaceable& x) const 34 {return int_ == x.int_ && double_ == x.double_;} 35 bool operator<(const Emplaceable& x) const 36 {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);} 37 38 int get() const {return int_;} 39 }; 40 41 namespace std { 42 43 template <> 44 struct hash<Emplaceable> 45 : public std::unary_function<Emplaceable, std::size_t> 46 { 47 std::size_t operator()(const Emplaceable& x) const {return x.get();} 48 }; 49 50 } 51 52 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 53 54 #endif // EMPLACEABLE_H 55