]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/yap/test/compile_is_expr.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / yap / test / compile_is_expr.cpp
1 // Copyright (C) 2016-2018 T. Zachary Laine
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/yap/expression.hpp>
7
8
9 namespace yap = boost::yap;
10
11 struct alternate_expr_1
12 {
13 static const yap::expr_kind kind = yap::expr_kind::plus;
14 boost::hana::tuple<> elements;
15 };
16
17 struct alternate_expr_2
18 {
19 static const yap::expr_kind kind = yap::expr_kind::plus;
20 boost::hana::tuple<int, double> elements;
21 };
22
23
24 struct non_expr_1
25 {};
26
27 struct non_expr_2
28 {
29 boost::hana::tuple<int, double> elements;
30 };
31
32 struct non_expr_3
33 {
34 static const int kind = 0;
35 boost::hana::tuple<int, double> elements;
36 };
37
38 struct non_expr_4
39 {
40 int kind;
41 boost::hana::tuple<int, double> elements;
42 };
43
44 struct non_expr_5
45 {
46 static const yap::expr_kind kind = yap::expr_kind::plus;
47 };
48
49 struct non_expr_6
50 {
51 static const yap::expr_kind kind = yap::expr_kind::plus;
52 int elements;
53 };
54
55
56 void compile_is_expr()
57 {
58 static_assert(
59 yap::is_expr<yap::terminal<yap::expression, double>>::value, "");
60
61 static_assert(
62 yap::is_expr<yap::terminal<yap::expression, double> const>::value, "");
63 static_assert(
64 yap::is_expr<yap::terminal<yap::expression, double> const &>::value,
65 "");
66 static_assert(
67 yap::is_expr<yap::terminal<yap::expression, double> &>::value, "");
68 static_assert(
69 yap::is_expr<yap::terminal<yap::expression, double> &&>::value, "");
70
71 {
72 using namespace yap::literals;
73 static_assert(yap::is_expr<decltype(1_p)>::value, "");
74 }
75
76 static_assert(
77 yap::is_expr<yap::expression<
78 yap::expr_kind::unary_plus,
79 boost::hana::tuple<yap::terminal<yap::expression, double>>>>::value,
80 "");
81 static_assert(
82 yap::is_expr<yap::expression<
83 yap::expr_kind::plus,
84 boost::hana::tuple<
85 yap::terminal<yap::expression, double>,
86 yap::terminal<yap::expression, double>>>>::value,
87 "");
88
89 static_assert(yap::is_expr<alternate_expr_1>::value, "");
90 static_assert(yap::is_expr<alternate_expr_2>::value, "");
91
92 static_assert(!yap::is_expr<int>::value, "");
93 static_assert(!yap::is_expr<non_expr_1>::value, "");
94 static_assert(!yap::is_expr<non_expr_2>::value, "");
95 static_assert(!yap::is_expr<non_expr_3>::value, "");
96 static_assert(!yap::is_expr<non_expr_4>::value, "");
97 static_assert(!yap::is_expr<non_expr_5>::value, "");
98 static_assert(!yap::is_expr<non_expr_6>::value, "");
99 }