]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/type/integral.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / type / integral.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)
4
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>
9
10 #include <type_traits>
11 namespace hana = boost::hana;
12
13
14 struct x1; struct x2; struct x3;
15 struct y1 { }; struct y2 { }; struct y3 { };
16
17 template <typename ...> struct mf { struct type { }; };
18 struct mfc { template <typename ...> struct apply { struct type { }; }; };
19 template <typename ...> struct tpl { };
20
21 // make sure `integral(f)(...)` returns the right type
22 static_assert(std::is_same<
23 decltype(hana::integral(hana::metafunction<mf>)()),
24 mf<>::type
25 >{}, "");
26 static_assert(std::is_same<
27 decltype(hana::integral(hana::metafunction<mf>)(hana::type_c<x1>)),
28 mf<x1>::type
29 >{}, "");
30 static_assert(std::is_same<
31 decltype(hana::integral(hana::metafunction<mf>)(hana::type_c<x1>, hana::type_c<x2>)),
32 mf<x1, x2>::type
33 >{}, "");
34
35 static_assert(std::is_same<
36 decltype(hana::integral(hana::template_<tpl>)()),
37 tpl<>
38 >{}, "");
39 static_assert(std::is_same<
40 decltype(hana::integral(hana::template_<tpl>)(hana::type_c<x1>)),
41 tpl<x1>
42 >{}, "");
43 static_assert(std::is_same<
44 decltype(hana::integral(hana::template_<tpl>)(hana::type_c<x1>, hana::type_c<x2>)),
45 tpl<x1, x2>
46 >{}, "");
47
48 static_assert(std::is_same<
49 decltype(hana::integral(hana::metafunction_class<mfc>)()),
50 mfc::apply<>::type
51 >{}, "");
52 static_assert(std::is_same<
53 decltype(hana::integral(hana::metafunction_class<mfc>)(hana::type_c<x1>)),
54 mfc::apply<x1>::type
55 >{}, "");
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
59 >{}, "");
60
61
62 int main() {
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;
68
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);
72 (void)r;
73 }