| 1 | // Copyright Louis Dionne 2013-2022 |
| 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 | namespace hana = boost::hana; |
| 10 | |
| 11 | |
| 12 | struct Empty { }; |
| 13 | |
| 14 | int main() { |
| 15 | { |
| 16 | using T = hana::tuple<>; |
| 17 | T t0; |
| 18 | T t_implicit = t0; |
| 19 | T t_explicit(t0); |
| 20 | |
| 21 | (void)t_explicit; |
| 22 | (void)t_implicit; |
| 23 | } |
| 24 | { |
| 25 | using T = hana::tuple<int>; |
| 26 | T t0(2); |
| 27 | T t = t0; |
| 28 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); |
| 29 | } |
| 30 | { |
| 31 | using T = hana::tuple<int, char>; |
| 32 | T t0(2, 'a'); |
| 33 | T t = t0; |
| 34 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); |
| 35 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); |
| 36 | } |
| 37 | { |
| 38 | using T = hana::tuple<int, char, std::string>; |
| 39 | const T t0(2, 'a', "some text" ); |
| 40 | T t = t0; |
| 41 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); |
| 42 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); |
| 43 | BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text" ); |
| 44 | } |
| 45 | { |
| 46 | using T = hana::tuple<int>; |
| 47 | constexpr T t0(2); |
| 48 | constexpr T t = t0; |
| 49 | static_assert(hana::at_c<0>(xs: t) == 2, "" ); |
| 50 | } |
| 51 | { |
| 52 | using T = hana::tuple<Empty>; |
| 53 | constexpr T t0; |
| 54 | constexpr T t = t0; |
| 55 | constexpr Empty e = hana::at_c<0>(xs: t); (void)e; |
| 56 | } |
| 57 | { |
| 58 | struct T { }; |
| 59 | struct U { }; |
| 60 | |
| 61 | constexpr hana::tuple<T, U> binary{}; |
| 62 | constexpr hana::tuple<T, U> copy_implicit = binary; |
| 63 | constexpr hana::tuple<T, U> copy_explicit(binary); |
| 64 | |
| 65 | (void)copy_implicit; |
| 66 | (void)copy_explicit; |
| 67 | } |
| 68 | } |
| 69 | |