]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / cnstr.convert_copy.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>
7namespace hana = boost::hana;
8
9
10struct A {
11 int id_;
12 constexpr A(int i) : id_(i) {}
13 friend constexpr bool operator==(const A& x, const A& y)
14 { return x.id_ == y.id_; }
15};
16
17struct B {
18 int id_;
19 explicit B(int i) : id_(i) {}
20};
21
22struct C {
23 int id_;
24 constexpr explicit C(int i) : id_(i) {}
25 friend constexpr bool operator==(const C& x, const C& y)
26 { return x.id_ == y.id_; }
27};
28
29struct D : B {
30 explicit D(int i) : B(i) {}
31};
32
33
34int main() {
35 {
36 using T0 = hana::tuple<double>;
37 using T1 = hana::tuple<int>;
38 T0 t0(2.5);
39 T1 t1 = t0;
40 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
41 }
42 {
43 using T0 = hana::tuple<double>;
44 using T1 = hana::tuple<A>;
45 constexpr T0 t0(2.5);
46 constexpr T1 t1 = t0;
47 static_assert(hana::at_c<0>(t1) == 2, "");
48 }
49 {
50 using T0 = hana::tuple<int>;
51 using T1 = hana::tuple<C>;
52 constexpr T0 t0(2);
53 constexpr T1 t1{t0};
54 static_assert(hana::at_c<0>(t1) == C(2), "");
55 }
56 {
57 using T0 = hana::tuple<double, char>;
58 using T1 = hana::tuple<int, int>;
59 T0 t0(2.5, 'a');
60 T1 t1 = t0;
61 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
62 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
63 }
64 {
65 using T0 = hana::tuple<double, char, D>;
66 using T1 = hana::tuple<int, int, B>;
67 T0 t0(2.5, 'a', D(3));
68 T1 t1 = 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 {
74 D d(3);
75 using T0 = hana::tuple<double, char, D&>;
76 using T1 = hana::tuple<int, int, B&>;
77 T0 t0(2.5, 'a', d);
78 T1 t1 = t0;
79 d.id_ = 2;
80 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
81 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
82 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2);
83 }
84 {
85 using T0 = hana::tuple<double, char, int>;
86 using T1 = hana::tuple<int, int, B>;
87 T0 t0(2.5, 'a', 3);
88 T1 t1(t0);
89 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
90 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
91 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3);
92 }
93}