]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/type/template.cpp
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/assert.hpp>
6 #include <boost/hana/concept/metafunction.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/not.hpp>
9 #include <boost/hana/type.hpp>
11 #include <type_traits>
12 namespace hana
= boost::hana
;
15 struct x1
; struct x2
; struct x3
;
16 struct y1
{ }; struct y2
{ }; struct y3
{ };
17 template <typename
...> struct f
;
19 BOOST_HANA_CONSTANT_CHECK(hana::equal(
23 BOOST_HANA_CONSTANT_CHECK(hana::equal(
24 hana::template_
<f
>(hana::type_c
<x1
>),
27 BOOST_HANA_CONSTANT_CHECK(hana::equal(
28 hana::template_
<f
>(hana::type_c
<x1
>, hana::type_c
<x2
>),
29 hana::type_c
<f
<x1
, x2
>>
31 BOOST_HANA_CONSTANT_CHECK(hana::equal(
32 hana::template_
<f
>(hana::type_c
<x1
>, hana::type_c
<x2
>, hana::type_c
<x3
>),
33 hana::type_c
<f
<x1
, x2
, x3
>>
36 using F
= decltype(hana::template_
<f
>);
37 static_assert(std::is_same
<F::apply
<>::type
, f
<>>{}, "");
38 static_assert(std::is_same
<F::apply
<x1
>::type
, f
<x1
>>{}, "");
39 static_assert(std::is_same
<F::apply
<x1
, x2
>::type
, f
<x1
, x2
>>{}, "");
40 static_assert(std::is_same
<F::apply
<x1
, x2
, x3
>::type
, f
<x1
, x2
, x3
>>{}, "");
42 // Make sure we model the Metafunction concept
43 static_assert(hana::Metafunction
<decltype(hana::template_
<f
>)>::value
, "");
44 static_assert(hana::Metafunction
<decltype(hana::template_
<f
>)&>::value
, "");
46 // Make sure we can use aliases
47 template <typename T
> using alias
= T
;
48 static_assert(hana::template_
<alias
>(hana::type_c
<x1
>) == hana::type_c
<x1
>, "");
50 // Make sure template_ is SFINAE-friendly
51 template <typename T
> struct unary
;
52 BOOST_HANA_CONSTANT_CHECK(hana::not_(
53 hana::is_valid(hana::template_
<unary
>)(hana::type_c
<void>, hana::type_c
<void>)
56 // Make sure we don't read from a non-constexpr variable
58 auto t
= hana::type_c
<x1
>;
59 constexpr auto r
= hana::template_
<f
>(t
);