]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/type/template.cpp
update sources to v12.2.3
[ceph.git] / 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)
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 template <typename ...> struct f;
17
18 BOOST_HANA_CONSTANT_CHECK(hana::equal(
19 hana::template_<f>(),
20 hana::type_c<f<>>
21 ));
22 BOOST_HANA_CONSTANT_CHECK(hana::equal(
23 hana::template_<f>(hana::type_c<x1>),
24 hana::type_c<f<x1>>
25 ));
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>>
29 ));
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>>
33 ));
34
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>>{}, "");
40
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, "");
44
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>, "");
48
49
50 // Make sure we don't read from a non-constexpr variable
51 int main() {
52 auto t = hana::type_c<x1>;
53 constexpr auto r = hana::template_<f>(t);
54 (void)r;
55 }