]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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>
11namespace hana = boost::hana;
12
13
14struct x1; struct x2; struct x3;
15struct y1 { }; struct y2 { }; struct y3 { };
16template <typename ...> struct f;
17
18BOOST_HANA_CONSTANT_CHECK(hana::equal(
19 hana::template_<f>(),
20 hana::type_c<f<>>
21));
22BOOST_HANA_CONSTANT_CHECK(hana::equal(
23 hana::template_<f>(hana::type_c<x1>),
24 hana::type_c<f<x1>>
25));
26BOOST_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));
30BOOST_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
35using F = decltype(hana::template_<f>);
36static_assert(std::is_same<F::apply<>::type, f<>>{}, "");
37static_assert(std::is_same<F::apply<x1>::type, f<x1>>{}, "");
38static_assert(std::is_same<F::apply<x1, x2>::type, f<x1, x2>>{}, "");
39static_assert(std::is_same<F::apply<x1, x2, x3>::type, f<x1, x2, x3>>{}, "");
40
41// Make sure we model the Metafunction concept
42static_assert(hana::Metafunction<decltype(hana::template_<f>)>::value, "");
43static_assert(hana::Metafunction<decltype(hana::template_<f>)&>::value, "");
44
45// Make sure we can use aliases
46template <typename T> using alias = T;
47static_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
51int main() {
52 auto t = hana::type_c<x1>;
53 constexpr auto r = hana::template_<f>(t);
54 (void)r;
55}