mirror of
https://github.com/boostorg/yap.git
synced 2026-02-22 16:02:10 +00:00
209 lines
5.1 KiB
C++
209 lines
5.1 KiB
C++
#include "expression.hpp"
|
|
|
|
#include <string>
|
|
|
|
|
|
template <typename T>
|
|
using term = boost::proto17::terminal<T>;
|
|
|
|
namespace bp17 = boost::proto17;
|
|
namespace bh = boost::hana;
|
|
|
|
|
|
void compile_term_plus_x ()
|
|
{
|
|
using namespace std::literals;
|
|
|
|
// char const * string
|
|
{
|
|
term<double> unity{1.0};
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<char const *>
|
|
>
|
|
> unevaluated_expr = unity + "3";
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
// std::string temporary
|
|
{
|
|
term<double> unity{1.0};
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<std::string>
|
|
>
|
|
> unevaluated_expr = unity + "3"s;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
// arrays
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int *>
|
|
>
|
|
> unevaluated_expr = unity + ints;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int const ints[] = {1, 2};
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int const *>
|
|
>
|
|
> unevaluated_expr = unity + ints;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int *>
|
|
>
|
|
> unevaluated_expr = unity + std::move(ints);
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
// pointers
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
int * int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int * &>
|
|
>
|
|
> unevaluated_expr = unity + int_ptr;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int const ints[] = {1, 2};
|
|
int const * int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int const * &>
|
|
>
|
|
> unevaluated_expr = unity + int_ptr;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
int * int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int *>
|
|
>
|
|
> unevaluated_expr = unity + std::move(int_ptr);
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
// const pointers
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
int * const int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int * const &>
|
|
>
|
|
> unevaluated_expr = unity + int_ptr;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int const ints[] = {1, 2};
|
|
int const * const int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int const * const &>
|
|
>
|
|
> unevaluated_expr = unity + int_ptr;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int ints[] = {1, 2};
|
|
int * const int_ptr = ints;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int * const>
|
|
>
|
|
> unevaluated_expr = unity + std::move(int_ptr);
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
// values
|
|
{
|
|
term<double> unity{1.0};
|
|
int i = 1;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int &>
|
|
>
|
|
> unevaluated_expr = unity + i;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int const i = 1;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int const &>
|
|
>
|
|
> unevaluated_expr = unity + i;
|
|
(void)unevaluated_expr;
|
|
}
|
|
|
|
{
|
|
term<double> unity{1.0};
|
|
int i = 1;
|
|
bp17::expression<
|
|
bp17::expr_kind::plus,
|
|
bh::tuple<
|
|
bp17::expression_ref<term<double> &>,
|
|
term<int>
|
|
>
|
|
> unevaluated_expr = unity + std::move(i);
|
|
(void)unevaluated_expr;
|
|
}
|
|
}
|