]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/cnstr.trap.cpp
1 // Copyright Louis Dionne 2013-2017
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)
5 #include <boost/hana/tuple.hpp>
8 namespace hana
= boost::hana
;
11 // Make sure that the tuple(Yn&&...) is not preferred over copy constructors
12 // in single-element cases and other similar cases.
16 Trap1(Trap1
const&) = default;
17 Trap1(Trap1
&) = default;
18 Trap1(Trap1
&&) = default;
22 static_assert(sizeof(X
) && false,
23 "this constructor must not be instantiated");
29 Trap2(Trap2
const&) = default;
30 Trap2(Trap2
&) = default;
31 Trap2(Trap2
&&) = default;
34 Trap2(X
) { // not by reference
35 static_assert(sizeof(X
) && false,
36 "this constructor must not be instantiated");
42 Trap3(Trap3
const&) = default;
43 Trap3(Trap3
&) = default;
44 Trap3(Trap3
&&) = default;
47 constexpr explicit Trap3(X
&&) { // explicit, and constexpr
48 static_assert(sizeof(X
) && false,
49 "this constructor must not be instantiated");
54 template <typename Args
>
55 constexpr explicit Trap4(Args
&&) {
56 static_assert(sizeof(Args
) && false, "must never be instantiated");
59 Trap4(Trap4
const&) = default;
60 Trap4(Trap4
&&) = default;
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
));
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
));
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
));
103 // Just defining the structure used to cause a failure, because of the
104 // explicitly defaulted copy-constructor.
108 Foo(Foo
const&) = default;
109 Foo(Foo
&&) = default;
110 hana::tuple
<Trap4
> t
;