]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/cnstr.trap.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / 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/tuple.hpp>
6
7 #include <utility>
8 namespace hana = boost::hana;
9
10
11 // Make sure that the tuple(Yn&&...) is not preferred over the
12 // tuple(tuple<Yn...> const&) and the tuple(tuple<Yn...>&&)
13 // constructors when copy-constructing a tuple with a single
14 // element that can be constructed from tuple<Yn...> const& and
15 // tuple<Yn...>&&, respectively.
16
17 struct Trap1 {
18 Trap1() = default;
19 Trap1(Trap1 const&) = default;
20 Trap1(Trap1&) = default;
21 Trap1(Trap1&&) = default;
22
23 template <typename X>
24 Trap1(X&&) {
25 static_assert(sizeof(X) && false,
26 "this constructor must not be instantiated");
27 }
28 };
29
30 struct Trap2 {
31 Trap2() = default;
32 Trap2(Trap2 const&) = default;
33 Trap2(Trap2&) = default;
34 Trap2(Trap2&&) = default;
35
36 template <typename X>
37 Trap2(X) { // not by reference
38 static_assert(sizeof(X) && false,
39 "this constructor must not be instantiated");
40 }
41 };
42
43 int main() {
44 {
45 hana::tuple<Trap1> tuple{};
46 hana::tuple<Trap1> implicit_copy = tuple;
47 hana::tuple<Trap1> explicit_copy(tuple);
48 hana::tuple<Trap1> implicit_move = std::move(tuple);
49 hana::tuple<Trap1> explicit_move(std::move(tuple));
50
51 (void)implicit_copy;
52 (void)explicit_copy;
53 (void)implicit_move;
54 (void)explicit_move;
55 }
56
57 {
58 hana::tuple<Trap2> tuple{};
59 hana::tuple<Trap2> implicit_copy = tuple;
60 hana::tuple<Trap2> explicit_copy(tuple);
61 hana::tuple<Trap2> implicit_move = std::move(tuple);
62 hana::tuple<Trap2> explicit_move(std::move(tuple));
63
64 (void)implicit_copy;
65 (void)explicit_copy;
66 (void)implicit_move;
67 (void)explicit_move;
68 }
69 }