]>
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/type.hpp>
10 #include <type_traits>
11 namespace hana
= boost::hana
;
14 struct x1
; struct x2
; struct x3
;
15 struct y1
{ }; struct y2
{ }; struct y3
{ };
16 template <typename
...> struct f
;
18 BOOST_HANA_CONSTANT_CHECK(hana::equal(
22 BOOST_HANA_CONSTANT_CHECK(hana::equal(
23 hana::template_
<f
>(hana::type_c
<x1
>),
26 BOOST_HANA_CONSTANT_CHECK(hana::equal(
27 hana::template_
<f
>(hana::type_c
<x1
>, hana::type_c
<x2
>),
28 hana::type_c
<f
<x1
, x2
>>
30 BOOST_HANA_CONSTANT_CHECK(hana::equal(
31 hana::template_
<f
>(hana::type_c
<x1
>, hana::type_c
<x2
>, hana::type_c
<x3
>),
32 hana::type_c
<f
<x1
, x2
, x3
>>
35 using F
= decltype(hana::template_
<f
>);
36 static_assert(std::is_same
<F::apply
<>::type
, f
<>>{}, "");
37 static_assert(std::is_same
<F::apply
<x1
>::type
, f
<x1
>>{}, "");
38 static_assert(std::is_same
<F::apply
<x1
, x2
>::type
, f
<x1
, x2
>>{}, "");
39 static_assert(std::is_same
<F::apply
<x1
, x2
, x3
>::type
, f
<x1
, x2
, x3
>>{}, "");
41 // Make sure we model the Metafunction concept
42 static_assert(hana::Metafunction
<decltype(hana::template_
<f
>)>::value
, "");
43 static_assert(hana::Metafunction
<decltype(hana::template_
<f
>)&>::value
, "");
45 // Make sure we can use aliases
46 template <typename T
> using alias
= T
;
47 static_assert(hana::template_
<alias
>(hana::type_c
<x1
>) == hana::type_c
<x1
>, "");
50 // Make sure we don't read from a non-constexpr variable
52 auto t
= hana::type_c
<x1
>;
53 constexpr auto r
= hana::template_
<f
>(t
);