]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.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/assert.hpp>
6 #include <boost/hana/tuple.hpp>
9 namespace hana
= boost::hana
;
14 MoveOnly(MoveOnly
const&) = delete;
15 MoveOnly
& operator=(MoveOnly
const&) = delete;
16 MoveOnly(int data
= 1) : data_(data
) { }
17 MoveOnly(MoveOnly
&& x
) : data_(x
.data_
) { x
.data_
= 0; }
19 MoveOnly
& operator=(MoveOnly
&& x
)
20 { data_
= x
.data_
; x
.data_
= 0; return *this; }
22 int get() const {return data_
;}
23 bool operator==(const MoveOnly
& x
) const { return data_
== x
.data_
; }
24 bool operator< (const MoveOnly
& x
) const { return data_
< x
.data_
; }
30 explicit constexpr A(int i
) : id_(i
) {}
33 struct NoDefault
{ NoDefault() = delete; };
37 hana::tuple
<MoveOnly
> t(MoveOnly(0));
38 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
41 hana::tuple
<MoveOnly
, MoveOnly
> t(MoveOnly(0), MoveOnly(1));
42 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
43 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 1);
46 hana::tuple
<MoveOnly
, MoveOnly
, MoveOnly
> t(
47 MoveOnly(0), MoveOnly(1), MoveOnly(2)
49 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
50 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 1);
51 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<2>(t
) == 2);
54 constexpr hana::tuple
<Empty
> t0
{Empty()};
57 constexpr hana::tuple
<A
, A
> t(3, 2);
58 static_assert(hana::at_c
<0>(t
).id_
== 3, "");
61 typedef hana::tuple
<MoveOnly
, NoDefault
> Tuple
;
63 static_assert(!std::is_constructible
<
68 static_assert(std::is_constructible
<
74 typedef hana::tuple
<MoveOnly
, MoveOnly
, NoDefault
> Tuple
;
76 static_assert(!std::is_constructible
<
81 static_assert(std::is_constructible
<
83 MoveOnly
, MoveOnly
, NoDefault
87 typedef hana::tuple
<MoveOnly
, NoDefault
> Tuple
;
88 typedef hana::tuple
<MoveOnly
, Tuple
, MoveOnly
, MoveOnly
> NestedTuple
;
90 static_assert(!std::is_constructible
<
92 MoveOnly
, MoveOnly
, MoveOnly
, MoveOnly
95 static_assert(std::is_constructible
<
97 MoveOnly
, Tuple
, MoveOnly
, MoveOnly
101 typedef hana::tuple
<MoveOnly
, int> Tuple
;
102 typedef hana::tuple
<MoveOnly
, Tuple
, MoveOnly
, MoveOnly
> NestedTuple
;
104 static_assert(!std::is_constructible
<
106 MoveOnly
, MoveOnly
, MoveOnly
, MoveOnly
109 static_assert(std::is_constructible
<
111 MoveOnly
, Tuple
, MoveOnly
, MoveOnly