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 104684ddb6SLionel Sambuc #ifndef EMPLACEABLE_H 114684ddb6SLionel Sambuc #define EMPLACEABLE_H 124684ddb6SLionel Sambuc 134684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 144684ddb6SLionel Sambuc 154684ddb6SLionel Sambuc class Emplaceable 164684ddb6SLionel Sambuc { 174684ddb6SLionel Sambuc Emplaceable(const Emplaceable&); 184684ddb6SLionel Sambuc Emplaceable& operator=(const Emplaceable&); 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambuc int int_; 214684ddb6SLionel Sambuc double double_; 224684ddb6SLionel Sambuc public: Emplaceable()234684ddb6SLionel Sambuc Emplaceable() : int_(0), double_(0) {} Emplaceable(int i,double d)244684ddb6SLionel Sambuc Emplaceable(int i, double d) : int_(i), double_(d) {} Emplaceable(Emplaceable && x)254684ddb6SLionel Sambuc Emplaceable(Emplaceable&& x) 264684ddb6SLionel Sambuc : int_(x.int_), double_(x.double_) 274684ddb6SLionel Sambuc {x.int_ = 0; x.double_ = 0;} 284684ddb6SLionel Sambuc Emplaceable& operator=(Emplaceable&& x) 294684ddb6SLionel Sambuc {int_ = x.int_; x.int_ = 0; 304684ddb6SLionel Sambuc double_ = x.double_; x.double_ = 0; 314684ddb6SLionel Sambuc return *this;} 324684ddb6SLionel Sambuc 334684ddb6SLionel Sambuc bool operator==(const Emplaceable& x) const 344684ddb6SLionel Sambuc {return int_ == x.int_ && double_ == x.double_;} 354684ddb6SLionel Sambuc bool operator<(const Emplaceable& x) const 364684ddb6SLionel Sambuc {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);} 374684ddb6SLionel Sambuc get()384684ddb6SLionel Sambuc int get() const {return int_;} 394684ddb6SLionel Sambuc }; 404684ddb6SLionel Sambuc 414684ddb6SLionel Sambuc namespace std { 424684ddb6SLionel Sambuc 434684ddb6SLionel Sambuc template <> 444684ddb6SLionel Sambuc struct hash<Emplaceable> 454684ddb6SLionel Sambuc : public std::unary_function<Emplaceable, std::size_t> 464684ddb6SLionel Sambuc { 474684ddb6SLionel Sambuc std::size_t operator()(const Emplaceable& x) const {return x.get();} 484684ddb6SLionel Sambuc }; 494684ddb6SLionel Sambuc 504684ddb6SLionel Sambuc } 514684ddb6SLionel Sambuc 524684ddb6SLionel Sambuc #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 534684ddb6SLionel Sambuc 544684ddb6SLionel Sambuc #endif // EMPLACEABLE_H 55