]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/set/cnstr.trap.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / set / cnstr.trap.cpp
1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/bool.hpp>
6 #include <boost/hana/detail/wrong.hpp>
7 #include <boost/hana/fwd/hash.hpp>
8 #include <boost/hana/set.hpp>
9 #include <boost/hana/type.hpp>
10
11 #include <utility>
12 namespace hana = boost::hana;
13
14
15 // This test makes sure that we do not instantiate rogue constructors when
16 // doing copies and moves
17
18 template <int i>
19 struct Trap {
20 Trap() = default;
21 Trap(Trap const&) = default;
22 Trap(Trap&) = default;
23 Trap(Trap&&) = default;
24
25 template <typename X>
26 Trap(X&&) {
27 static_assert(hana::detail::wrong<X>{},
28 "this constructor must not be instantiated");
29 }
30 };
31
32 template <int i, int j>
33 constexpr auto operator==(Trap<i> const&, Trap<j> const&)
34 { return hana::bool_c<i == j>; }
35
36 template <int i, int j>
37 constexpr auto operator!=(Trap<i> const&, Trap<j> const&)
38 { return hana::bool_c<i != j>; }
39
40 namespace boost { namespace hana {
41 template <int i>
42 struct hash_impl<Trap<i>> {
43 static constexpr auto apply(Trap<i> const&)
44 { return hana::type_c<Trap<i>>; };
45 };
46 }}
47
48 int main() {
49 {
50 auto expr = hana::make_set(Trap<0>{});
51 auto implicit_copy = expr;
52 decltype(expr) explicit_copy(expr);
53
54 (void)implicit_copy;
55 (void)explicit_copy;
56 }
57 {
58 auto expr = hana::make_set(Trap<0>{});
59 auto implicit_move = std::move(expr);
60 decltype(expr) explicit_move(std::move(implicit_move));
61
62 (void)implicit_move;
63 (void)explicit_move;
64 }
65 }