Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / Emplaceable.h
blobca780d0ae1fe266b1c95abdd73c8b74cf2abfc52
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 namespace std {
45 template <>
46 struct hash<Emplaceable>
48 typedef Emplaceable argument_type;
49 typedef std::size_t result_type;
51 std::size_t operator()(const Emplaceable& x) const {return x.get();}
56 #endif // TEST_STD_VER >= 11
57 #endif // EMPLACEABLE_H