]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/tuple/assign.convert_move.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / assign.convert_move.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/assert.hpp>
6#include <boost/hana/tuple.hpp>
7
8#include <memory>
9#include <utility>
10namespace hana = boost::hana;
11
12
13struct B {
14 int id_;
15 explicit B(int i = 0) : id_(i) {}
16 virtual ~B() {}
17};
18
19struct D : B {
20 explicit D(int i) : B(i) {}
21};
22
23int main() {
24 {
25 using T0 = hana::tuple<double>;
26 using T1 = hana::tuple<int>;
27 T0 t0(2.5);
28 T1 t1;
29 t1 = std::move(t0);
30 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
31 }
32 {
33 using T0 = hana::tuple<double, char>;
34 using T1 = hana::tuple<int, int>;
35 T0 t0(2.5, 'a');
36 T1 t1;
37 t1 = std::move(t0);
38 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
39 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
40 }
41 {
42 using T0 = hana::tuple<double, char, D>;
43 using T1 = hana::tuple<int, int, B>;
44 T0 t0(2.5, 'a', D(3));
45 T1 t1;
46 t1 = std::move(t0);
47 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
48 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
49 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3);
50 }
51 {
52 D d(3);
53 D d2(2);
54 using T0 = hana::tuple<double, char, D&>;
55 using T1 = hana::tuple<int, int, B&>;
56 T0 t0(2.5, 'a', d2);
57 T1 t1(1.5, 'b', d);
58 t1 = std::move(t0);
59 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
60 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
61 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2);
62 }
63 {
64 using T0 = hana::tuple<double, char, std::unique_ptr<D>>;
65 using T1 = hana::tuple<int, int, std::unique_ptr<B>>;
66 T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
67 T1 t1;
68 t1 = std::move(t0);
69 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
70 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
71 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3);
72 }
73}