Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / Emplaceable.h
blob1a4e14505fb21ed04f4617c4b48ec46863197b86
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef EMPLACEABLE_H
10 #define EMPLACEABLE_H
12 #include <functional>
13 #include "test_macros.h"
15 #if TEST_STD_VER >= 11
17 class Emplaceable
19 Emplaceable(const Emplaceable&);
20 Emplaceable& operator=(const Emplaceable&);
22 int int_;
23 double double_;
24 public:
25 Emplaceable() : int_(0), double_(0) {}
26 Emplaceable(int i, double d) : int_(i), double_(d) {}
27 Emplaceable(Emplaceable&& x)
28 : int_(x.int_), double_(x.double_)
29 {x.int_ = 0; x.double_ = 0;}
30 Emplaceable& operator=(Emplaceable&& x)
31 {int_ = x.int_; x.int_ = 0;
32 double_ = x.double_; x.double_ = 0;
33 return *this;}
35 bool operator==(const Emplaceable& x) const
36 {return int_ == x.int_ && double_ == x.double_;}
37 bool operator<(const Emplaceable& x) const
38 {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
40 int get() const {return int_;}
43 template <>
44 struct std::hash<Emplaceable> {
45 typedef Emplaceable argument_type;
46 typedef std::size_t result_type;
48 std::size_t operator()(const Emplaceable& x) const { return x.get(); }
51 #endif // TEST_STD_VER >= 11
52 #endif // EMPLACEABLE_H