]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/usability_of_types.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/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>
12 #include <type_traits>
13 namespace hana
= boost::hana
;
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
22 struct T
; struct U
; struct V
;
25 auto check
= [](auto types
) {
26 static_assert(std::is_same
<
27 typename
decltype(+hana::front(types
))::type
, T
30 static_assert(std::is_same
<
31 typename
decltype(+hana::at(types
, hana::size_c
<1>))::type
, U
34 static_assert(std::is_same
<
35 typename
decltype(+hana::back(types
))::type
, V
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
>);