]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/type/integral.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/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
{ };
17 template <typename
...> struct mf
{ struct type
{ }; };
18 struct mfc
{ template <typename
...> struct apply
{ struct type
{ }; }; };
19 template <typename
...> struct tpl
{ };
21 // make sure `integral(f)(...)` returns the right type
22 static_assert(std::is_same
<
23 decltype(hana::integral(hana::metafunction
<mf
>)()),
26 static_assert(std::is_same
<
27 decltype(hana::integral(hana::metafunction
<mf
>)(hana::type_c
<x1
>)),
30 static_assert(std::is_same
<
31 decltype(hana::integral(hana::metafunction
<mf
>)(hana::type_c
<x1
>, hana::type_c
<x2
>)),
35 static_assert(std::is_same
<
36 decltype(hana::integral(hana::template_
<tpl
>)()),
39 static_assert(std::is_same
<
40 decltype(hana::integral(hana::template_
<tpl
>)(hana::type_c
<x1
>)),
43 static_assert(std::is_same
<
44 decltype(hana::integral(hana::template_
<tpl
>)(hana::type_c
<x1
>, hana::type_c
<x2
>)),
48 static_assert(std::is_same
<
49 decltype(hana::integral(hana::metafunction_class
<mfc
>)()),
52 static_assert(std::is_same
<
53 decltype(hana::integral(hana::metafunction_class
<mfc
>)(hana::type_c
<x1
>)),
56 static_assert(std::is_same
<
57 decltype(hana::integral(hana::metafunction_class
<mfc
>)(hana::type_c
<x1
>, hana::type_c
<x2
>)),
58 mfc::apply
<x1
, x2
>::type
63 // Make sure we can perform the call; we already made sure the return type was correct
64 constexpr auto a
= hana::integral(hana::metafunction
<mf
>)(); (void)a
;
65 constexpr auto b
= hana::integral(hana::metafunction
<mf
>)(hana::type_c
<x1
>); (void)b
;
66 constexpr auto c
= hana::integral(hana::metafunction
<mf
>)(hana::type_c
<x1
>, hana::type_c
<x2
>); (void)c
;
67 constexpr auto d
= hana::integral(hana::metafunction
<mf
>)(hana::type_c
<x1
>, hana::type_c
<x2
>, hana::type_c
<x3
>); (void)d
;
69 // Make sure we don't read from a non-constexpr variable
70 auto t
= hana::type_c
<x1
>;
71 constexpr auto r
= hana::integral(hana::metafunction
<mf
>)(t
);