1*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===// 2*0a6a1f1dSLionel Sambuc // 3*0a6a1f1dSLionel Sambuc // The LLVM Compiler Infrastructure 4*0a6a1f1dSLionel Sambuc // 5*0a6a1f1dSLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 6*0a6a1f1dSLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 7*0a6a1f1dSLionel Sambuc // 8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===// 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc #ifndef EMPLACEABLE_H 11*0a6a1f1dSLionel Sambuc #define EMPLACEABLE_H 12*0a6a1f1dSLionel Sambuc 13*0a6a1f1dSLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc class Emplaceable 16*0a6a1f1dSLionel Sambuc { 17*0a6a1f1dSLionel Sambuc Emplaceable(const Emplaceable&); 18*0a6a1f1dSLionel Sambuc Emplaceable& operator=(const Emplaceable&); 19*0a6a1f1dSLionel Sambuc 20*0a6a1f1dSLionel Sambuc int int_; 21*0a6a1f1dSLionel Sambuc double double_; 22*0a6a1f1dSLionel Sambuc public: Emplaceable()23*0a6a1f1dSLionel Sambuc Emplaceable() : int_(0), double_(0) {} Emplaceable(int i,double d)24*0a6a1f1dSLionel Sambuc Emplaceable(int i, double d) : int_(i), double_(d) {} Emplaceable(Emplaceable && x)25*0a6a1f1dSLionel Sambuc Emplaceable(Emplaceable&& x) 26*0a6a1f1dSLionel Sambuc : int_(x.int_), double_(x.double_) 27*0a6a1f1dSLionel Sambuc {x.int_ = 0; x.double_ = 0;} 28*0a6a1f1dSLionel Sambuc Emplaceable& operator=(Emplaceable&& x) 29*0a6a1f1dSLionel Sambuc {int_ = x.int_; x.int_ = 0; 30*0a6a1f1dSLionel Sambuc double_ = x.double_; x.double_ = 0; 31*0a6a1f1dSLionel Sambuc return *this;} 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambuc bool operator==(const Emplaceable& x) const 34*0a6a1f1dSLionel Sambuc {return int_ == x.int_ && double_ == x.double_;} 35*0a6a1f1dSLionel Sambuc bool operator<(const Emplaceable& x) const 36*0a6a1f1dSLionel Sambuc {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);} 37*0a6a1f1dSLionel Sambuc get()38*0a6a1f1dSLionel Sambuc int get() const {return int_;} 39*0a6a1f1dSLionel Sambuc }; 40*0a6a1f1dSLionel Sambuc 41*0a6a1f1dSLionel Sambuc namespace std { 42*0a6a1f1dSLionel Sambuc 43*0a6a1f1dSLionel Sambuc template <> 44*0a6a1f1dSLionel Sambuc struct hash<Emplaceable> 45*0a6a1f1dSLionel Sambuc : public std::unary_function<Emplaceable, std::size_t> 46*0a6a1f1dSLionel Sambuc { 47*0a6a1f1dSLionel Sambuc std::size_t operator()(const Emplaceable& x) const {return x.get();} 48*0a6a1f1dSLionel Sambuc }; 49*0a6a1f1dSLionel Sambuc 50*0a6a1f1dSLionel Sambuc } 51*0a6a1f1dSLionel Sambuc 52*0a6a1f1dSLionel Sambuc #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 53*0a6a1f1dSLionel Sambuc 54*0a6a1f1dSLionel Sambuc #endif // EMPLACEABLE_H 55