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)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/tuple.hpp>
7
8 #include <string>
9 #include <memory>
10 namespace hana = boost::hana;
11
12
13 struct B {
14 int id_;
BB15 explicit B(int i) : id_(i) {}
~BB16 virtual ~B() {}
17 };
18
19 struct D : B {
DD20 explicit D(int i) : B(i) {}
21 };
22
main()23 int main() {
24 {
25 using T0 = hana::tuple<double>;
26 using T1 = hana::tuple<int>;
27 T0 t0(2.5);
28 T1 t1 = std::move(t0);
29 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
30 }
31 {
32 using T0 = hana::tuple<double, char>;
33 using T1 = hana::tuple<int, int>;
34 T0 t0(2.5, 'a');
35 T1 t1 = std::move(t0);
36 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
37 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
38 }
39 {
40 using T0 = hana::tuple<double, char, D>;
41 using T1 = hana::tuple<int, int, B>;
42 T0 t0(2.5, 'a', D(3));
43 T1 t1 = std::move(t0);
44 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
45 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
46 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3);
47 }
48 {
49 D d(3);
50 using T0 = hana::tuple<double, char, D&>;
51 using T1 = hana::tuple<int, int, B&>;
52 T0 t0(2.5, 'a', d);
53 T1 t1 = std::move(t0);
54 d.id_ = 2;
55 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
56 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
57 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2);
58 }
59 {
60 using T0 = hana::tuple<double, char, std::unique_ptr<D>>;
61 using T1 = hana::tuple<int, int, std::unique_ptr<B>>;
62 T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
63 T1 t1 = std::move(t0);
64 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
65 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
66 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3);
67 }
68 }
69