• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/at.hpp>
7 #include <boost/hana/basic_tuple.hpp>
8 
9 #include <laws/base.hpp>
10 
11 #include <string>
12 namespace hana = boost::hana;
13 
14 
15 struct Empty { };
16 
main()17 int main() {
18     {
19         using T = hana::basic_tuple<>;
20         T t0;
21         T t_implicit = t0;
22         T t_explicit(t0);
23 
24         (void)t_explicit;
25         (void)t_implicit;
26     }
27     {
28         using T = hana::basic_tuple<int>;
29         T t0(2);
30         T t = t0;
31         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
32     }
33     {
34         using T = hana::basic_tuple<int, char>;
35         T t0(2, 'a');
36         T t = t0;
37         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
38         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a');
39     }
40     {
41         using T = hana::basic_tuple<int, char, std::string>;
42         const T t0(2, 'a', "some text");
43         T t = t0;
44         BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
45         BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a');
46         BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text");
47     }
48     {
49         using T = hana::basic_tuple<int>;
50         constexpr T t0(2);
51         constexpr T t = t0;
52         static_assert(hana::at_c<0>(t) == 2, "");
53     }
54     {
55         using T = hana::basic_tuple<Empty>;
56         constexpr T t0{};
57         constexpr T t = t0;
58         constexpr Empty e = hana::at_c<0>(t); (void)e;
59     }
60     {
61         struct T { };
62         struct U { };
63 
64         constexpr hana::basic_tuple<T, U> binary{};
65         constexpr hana::basic_tuple<T, U> copy_implicit = binary;
66         constexpr hana::basic_tuple<T, U> copy_explicit(binary);
67 
68         (void)copy_implicit;
69         (void)copy_explicit;
70     }
71 
72     // This used to fail
73     {
74         hana::basic_tuple<
75             hana::test::ct_eq<0>,
76             hana::test::ct_eq<2>,
77             hana::test::ct_eq<4>
78         > tuple{};
79 
80         hana::basic_tuple<
81             hana::test::ct_eq<0>,
82             hana::test::ct_eq<2>,
83             hana::test::ct_eq<4>
84         > copy(tuple);
85     }
86 }
87