]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/tuple/cnstr.trap.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / cnstr.trap.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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/tuple.hpp>
6
7#include <utility>
8namespace hana = boost::hana;
9
10
b32b8144
FG
11// Make sure that the tuple(Yn&&...) is not preferred over copy constructors
12// in single-element cases and other similar cases.
7c673cae
FG
13
14struct Trap1 {
15 Trap1() = default;
16 Trap1(Trap1 const&) = default;
17 Trap1(Trap1&) = default;
18 Trap1(Trap1&&) = default;
19
20 template <typename X>
21 Trap1(X&&) {
22 static_assert(sizeof(X) && false,
23 "this constructor must not be instantiated");
24 }
25};
26
27struct Trap2 {
28 Trap2() = default;
29 Trap2(Trap2 const&) = default;
30 Trap2(Trap2&) = default;
31 Trap2(Trap2&&) = default;
32
33 template <typename X>
34 Trap2(X) { // not by reference
35 static_assert(sizeof(X) && false,
36 "this constructor must not be instantiated");
37 }
38};
39
b32b8144
FG
40struct Trap3 {
41 Trap3() = default;
42 Trap3(Trap3 const&) = default;
43 Trap3(Trap3&) = default;
44 Trap3(Trap3&&) = default;
45
46 template <typename X>
47 constexpr explicit Trap3(X&&) { // explicit, and constexpr
48 static_assert(sizeof(X) && false,
49 "this constructor must not be instantiated");
50 }
51};
52
53struct Trap4 {
54 template <typename Args>
55 constexpr explicit Trap4(Args&&) {
56 static_assert(sizeof(Args) && false, "must never be instantiated");
57 }
58
59 Trap4(Trap4 const&) = default;
60 Trap4(Trap4&&) = default;
61};
62
7c673cae
FG
63int main() {
64 {
65 hana::tuple<Trap1> tuple{};
66 hana::tuple<Trap1> implicit_copy = tuple;
67 hana::tuple<Trap1> explicit_copy(tuple);
68 hana::tuple<Trap1> implicit_move = std::move(tuple);
69 hana::tuple<Trap1> explicit_move(std::move(tuple));
70
71 (void)implicit_copy;
72 (void)explicit_copy;
73 (void)implicit_move;
74 (void)explicit_move;
75 }
76
77 {
78 hana::tuple<Trap2> tuple{};
79 hana::tuple<Trap2> implicit_copy = tuple;
80 hana::tuple<Trap2> explicit_copy(tuple);
81 hana::tuple<Trap2> implicit_move = std::move(tuple);
82 hana::tuple<Trap2> explicit_move(std::move(tuple));
83
84 (void)implicit_copy;
85 (void)explicit_copy;
86 (void)implicit_move;
87 (void)explicit_move;
88 }
b32b8144
FG
89
90 {
91 hana::tuple<Trap3> tuple{};
92 hana::tuple<Trap3> implicit_copy = tuple;
93 hana::tuple<Trap3> explicit_copy(tuple);
94 hana::tuple<Trap3> implicit_move = std::move(tuple);
95 hana::tuple<Trap3> explicit_move(std::move(tuple));
96
97 (void)implicit_copy;
98 (void)explicit_copy;
99 (void)implicit_move;
100 (void)explicit_move;
101 }
102
103 // Just defining the structure used to cause a failure, because of the
104 // explicitly defaulted copy-constructor.
105 {
106 struct Foo {
107 Foo() = default;
108 Foo(Foo const&) = default;
109 Foo(Foo&&) = default;
110 hana::tuple<Trap4> t;
111 };
112 }
7c673cae 113}