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 namespace hana = boost::hana;
8 
9 
10 struct B {
11     int id_;
BB12     explicit B(int i = 0) : id_(i) { }
13 };
14 
15 struct D : B {
DD16     explicit D(int i = 0) : B(i) { }
17 };
18 
main()19 int main() {
20     {
21         using T0 = hana::tuple<double>;
22         using T1 = hana::tuple<int>;
23         T0 t0(2.5);
24         T1 t1;
25         t1 = t0;
26         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
27     }
28     {
29         using T0 = hana::tuple<double, char>;
30         using T1 = hana::tuple<int, int>;
31         T0 t0(2.5, 'a');
32         T1 t1;
33         t1 = t0;
34         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
35         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
36     }
37     {
38         using T0 = hana::tuple<double, char, D>;
39         using T1 = hana::tuple<int, int, B>;
40         T0 t0(2.5, 'a', D(3));
41         T1 t1;
42         t1 = t0;
43         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
44         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
45         BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3);
46     }
47     {
48         D d(3);
49         D d2(2);
50         using T0 = hana::tuple<double, char, D&>;
51         using T1 = hana::tuple<int, int, B&>;
52         T0 t0(2.5, 'a', d2);
53         T1 t1(1.5, 'b', d);
54         t1 = t0;
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