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 template<typename T>
10 using term = boost::yap::terminal<boost::yap::expression, T>;
11
12 template<typename T>
13 using ref = boost::yap::expression_ref<boost::yap::expression, T>;
14
15 namespace yap = boost::yap;
16 namespace bh = boost::hana;
17
18
compile_const_term()19 void compile_const_term()
20 {
21 {
22 term<double const> unity{1.0};
23 int i_ = 42;
24 term<int &&> i{std::move(i_)};
25 yap::expression<
26 yap::expr_kind::plus,
27 bh::tuple<ref<term<double const> &>, term<int &&>>>
28 expr = unity + std::move(i);
29 yap::expression<
30 yap::expr_kind::plus,
31 bh::tuple<
32 ref<term<double const> &>,
33 yap::expression<
34 yap::expr_kind::plus,
35 bh::tuple<ref<term<double const> &>, term<int &&>>>>>
36 unevaluated_expr = unity + std::move(expr);
37 (void)unevaluated_expr;
38 }
39
40 {
41 term<double> const unity{1.0};
42 int i_ = 42;
43 term<int &&> i{std::move(i_)};
44 yap::expression<
45 yap::expr_kind::plus,
46 bh::tuple<ref<term<double> const &>, term<int &&>>>
47 expr = unity + std::move(i);
48 yap::expression<
49 yap::expr_kind::plus,
50 bh::tuple<
51 ref<term<double> const &>,
52 yap::expression<
53 yap::expr_kind::plus,
54 bh::tuple<ref<term<double> const &>, term<int &&>>>>>
55 unevaluated_expr = unity + std::move(expr);
56 (void)unevaluated_expr;
57 }
58
59 {
60 term<double> unity{1.0};
61 int i_ = 42;
62 term<int const &> i{i_};
63 yap::expression<
64 yap::expr_kind::plus,
65 bh::tuple<ref<term<double> &>, term<int const &>>> const expr =
66 unity + std::move(i);
67 yap::expression<
68 yap::expr_kind::plus,
69 bh::tuple<
70 ref<term<double> &>,
71 yap::expression<
72 yap::expr_kind::plus,
73 bh::tuple<ref<term<double> &>, term<int const &>>>>>
74 unevaluated_expr = unity + std::move(expr);
75 (void)unevaluated_expr;
76 }
77 }
78