]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/at.non_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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/tuple.hpp>
9 namespace hana
= boost::hana
;
21 hana::tuple
<int, Empty
> a
;
26 constexpr hana::tuple
<int, int> getP () { return { 3, 4 }; }
30 using T
= hana::tuple
<int>;
32 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 3);
34 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 2);
37 using T
= hana::tuple
<std::string
, int>;
39 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == "high");
40 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 5);
41 hana::at_c
<0>(t
) = "four";
43 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == "four");
44 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == 4);
47 using T
= hana::tuple
<double&, std::string
, int>;
50 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 1.5);
51 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == "high");
52 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<2>(t
) == 5);
53 hana::at_c
<0>(t
) = 2.5;
54 hana::at_c
<1>(t
) = "four";
56 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<0>(t
) == 2.5);
57 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<1>(t
) == "four");
58 BOOST_HANA_RUNTIME_CHECK(hana::at_c
<2>(t
) == 4);
59 BOOST_HANA_RUNTIME_CHECK(d
== 2.5);
61 // get on a rvalue tuple
63 static_assert(hana::at_c
<0>(hana::tuple
<float, int, double, long>{0.0f
, 1, 2.0, 3L}) == 0, "" );
64 static_assert(hana::at_c
<1>(hana::tuple
<float, int, double, long>{0.0f
, 1, 2.0, 3L}) == 1, "" );
65 static_assert(hana::at_c
<2>(hana::tuple
<float, int, double, long>{0.0f
, 1, 2.0, 3L}) == 2, "" );
66 static_assert(hana::at_c
<3>(hana::tuple
<float, int, double, long>{0.0f
, 1, 2.0, 3L}) == 3, "" );
67 static_assert(S().k
== 1, "");
68 static_assert(hana::at_c
<1>(getP()) == 4, "");
71 // make sure get<> returns the right types
76 hana::tuple
<T
, U
, V
> xs
{};
77 (void)static_cast<T
>(hana::at_c
<0>(xs
));
78 (void)static_cast<U
>(hana::at_c
<1>(xs
));
79 (void)static_cast<V
>(hana::at_c
<2>(xs
));