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)
5 #include <boost/hana/at.hpp>
6 #include <boost/hana/first.hpp>
7 #include <boost/hana/integral_constant.hpp>
8 #include <boost/hana/pair.hpp>
9 #include <boost/hana/second.hpp>
10 #include <boost/hana/tuple.hpp>
12 #include <type_traits>
13 namespace hana = boost::hana;
16 // In GitHub issue #331, we noticed that `first` and `second` could sometimes
17 // return the wrong member in case of nested pairs. This is due to the way we
18 // inherit from base classes to enable EBO. We also check for `basic_tuple`,
19 // because both are implemented similarly.
23 using Nested = hana::pair<hana::int_<1>, hana::int_<2>>;
24 using Pair = hana::pair<hana::int_<0>, Nested>;
27 auto a = hana::first(pair);
28 static_assert(std::is_same<decltype(a), hana::int_<0>>{}, "");
30 auto b = hana::second(pair);
31 static_assert(std::is_same<decltype(b), Nested>{}, "");
35 using Nested = hana::basic_tuple<hana::int_<1>, hana::int_<2>>;
36 using Tuple = hana::basic_tuple<hana::int_<0>, Nested>;
39 auto a = hana::at_c<0>(tuple);
40 static_assert(std::is_same<decltype(a), hana::int_<0>>{}, "");
42 auto b = hana::at_c<1>(tuple);
43 static_assert(std::is_same<decltype(b), Nested>{}, "");