]>
Commit | Line | Data |
---|---|---|
b32b8144 | 1 | // Copyright Louis Dionne 2013-2017 |
7c673cae FG |
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/at.hpp> | |
6 | #include <boost/hana/back.hpp> | |
7 | #include <boost/hana/front.hpp> | |
8 | #include <boost/hana/integral_constant.hpp> | |
9 | #include <boost/hana/tuple.hpp> | |
10 | #include <boost/hana/type.hpp> | |
11 | ||
12 | #include <type_traits> | |
13 | namespace hana = boost::hana; | |
14 | ||
15 | ||
16 | // The fact that a reference to a `type<...>` is returned from `front(types)` | |
17 | // and friends used to break the `decltype(front(types))::type` pattern, | |
18 | // because we would be trying to fetch `::type` inside a reference. To work | |
19 | // around this, a unary `operator+` turning a lvalue `type` into a rvalue | |
20 | // `type` was added. | |
21 | ||
22 | struct T; struct U; struct V; | |
23 | ||
24 | int main() { | |
25 | auto check = [](auto types) { | |
26 | static_assert(std::is_same< | |
27 | typename decltype(+hana::front(types))::type, T | |
28 | >{}, ""); | |
29 | ||
30 | static_assert(std::is_same< | |
31 | typename decltype(+hana::at(types, hana::size_c<1>))::type, U | |
32 | >{}, ""); | |
33 | ||
34 | static_assert(std::is_same< | |
35 | typename decltype(+hana::back(types))::type, V | |
36 | >{}, ""); | |
37 | }; | |
38 | ||
39 | check(hana::make_tuple(hana::type_c<T>, hana::type_c<U>, hana::type_c<V>)); | |
40 | check(hana::tuple_t<T, U, V>); | |
41 | } |