]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/cnstr.move.cpp
d6612701aadd5fa91b6350578c6e885a6bf17d33
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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/tuple.hpp>
10 namespace hana
= boost::hana
;
15 MoveOnly(MoveOnly
const&) = delete;
16 MoveOnly
& operator=(MoveOnly
const&) = delete;
17 MoveOnly(int data
= 1) : data_(data
) { }
18 MoveOnly(MoveOnly
&& x
) : data_(x
.data_
) { x
.data_
= 0; }
20 MoveOnly
& operator=(MoveOnly
&& x
)
21 { data_
= x
.data_
; x
.data_
= 0; return *this; }
23 int get() const {return data_
;}
24 bool operator==(const MoveOnly
& x
) const { return data_
== x
.data_
; }
25 bool operator< (const MoveOnly
& x
) const { return data_
< x
.data_
; }
30 using T
= hana::tuple
<>;
32 T t
= std::move(t0
); (void)t
;
35 using T
= hana::tuple
<MoveOnly
>;
37 T t
= std::move(t0
); (void)t
;
38 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
41 using T
= hana::tuple
<MoveOnly
, MoveOnly
>;
42 T
t0(MoveOnly(0), MoveOnly(1));
43 T t
= std::move(t0
); (void)t
;
44 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
45 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 1);
48 using T
= hana::tuple
<MoveOnly
, MoveOnly
, MoveOnly
>;
49 T
t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
50 T t
= std::move(t0
); (void)t
;
51 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 0);
52 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 1);
53 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<2>(t
) == 2);
56 // Check for SFINAE-friendliness
57 static_assert(!std::is_constructible
<
58 hana::tuple
<MoveOnly
>, MoveOnly
const&
61 static_assert(!std::is_constructible
<
62 hana::tuple
<MoveOnly
>, MoveOnly
&
65 static_assert(std::is_constructible
<
66 hana::tuple
<MoveOnly
>, MoveOnly
69 static_assert(std::is_constructible
<
70 hana::tuple
<MoveOnly
>, MoveOnly
&&