]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/at.const.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / tuple / at.const.cpp
1 // Copyright Louis Dionne 2013-2016
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<int>;
17 const T t(3);
18 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3);
19 }
20 {
21 using T = hana::tuple<std::string, int>;
22 const T t("high", 5);
23 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high");
24 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5);
25 }
26 {
27 using T = hana::tuple<double, int>;
28 constexpr T t(2.718, 5);
29 static_assert(hana::at_c<0>(t) == 2.718, "");
30 static_assert(hana::at_c<1>(t) == 5, "");
31 }
32 {
33 using T = hana::tuple<Empty>;
34 constexpr T t{Empty()};
35 constexpr Empty e = hana::at_c<0>(t); (void)e;
36 }
37 {
38 using T = hana::tuple<double&, std::string, int>;
39 double d = 1.5;
40 const T t(d, "high", 5);
41 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5);
42 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high");
43 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5);
44 hana::at_c<0>(t) = 2.5;
45 BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5);
46 BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high");
47 BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5);
48 BOOST_HANA_RUNTIME_CHECK(d == 2.5);
49 }
50 }