1 // Copyright (C) 2016-2018 T. Zachary Laine
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 #include <boost/yap/print.hpp>
9 #include <boost/test/minimal.hpp>
16 using term
= boost::yap::terminal
<boost::yap::expression
, T
>;
19 using ref
= boost::yap::expression_ref
<boost::yap::expression
, T
>;
21 namespace yap
= boost::yap
;
22 namespace bh
= boost::hana
;
25 template<boost::yap::expr_kind Kind
, typename Tuple
>
28 static boost::yap::expr_kind
const kind
= Kind
;
33 BOOST_YAP_USER_BINARY_OPERATOR(plus
, user_expr
, user_expr
)
36 using user_term
= boost::yap::terminal
<user_expr
, T
>;
39 using user_ref
= boost::yap::expression_ref
<user_expr
, T
>;
44 std::string
fix_tti(std::string s
)
46 // msvc: remove struct/class prefixes
47 static const std::regex
estruct("(struct|class) ");
48 s
= std::regex_replace(s
, estruct
, "");
50 // gcc/clang: strip integral literals suffixes
51 static const std::regex
eint("(\\d)u?l{0,2}");
52 s
= std::regex_replace(s
, eint
, "$1");
57 int test_main(int, char * [])
61 yap::op_string(yap::expr_kind::terminal
) == std::string("term"));
63 yap::op_string(yap::expr_kind::unary_plus
) == std::string("+"));
64 BOOST_CHECK(yap::op_string(yap::expr_kind::negate
) == std::string("-"));
66 yap::op_string(yap::expr_kind::dereference
) == std::string("*"));
68 yap::op_string(yap::expr_kind::complement
) == std::string("~"));
70 yap::op_string(yap::expr_kind::address_of
) == std::string("&"));
72 yap::op_string(yap::expr_kind::logical_not
) == std::string("!"));
74 BOOST_CHECK(yap::op_string(yap::expr_kind::pre_inc
) == std::string("++"));
75 BOOST_CHECK(yap::op_string(yap::expr_kind::pre_dec
) == std::string("--"));
77 yap::op_string(yap::expr_kind::post_inc
) == std::string("++(int)"));
79 yap::op_string(yap::expr_kind::post_dec
) == std::string("--(int)"));
82 yap::op_string(yap::expr_kind::shift_left
) == std::string("<<"));
84 yap::op_string(yap::expr_kind::shift_right
) == std::string(">>"));
86 yap::op_string(yap::expr_kind::multiplies
) == std::string("*"));
87 BOOST_CHECK(yap::op_string(yap::expr_kind::divides
) == std::string("/"));
88 BOOST_CHECK(yap::op_string(yap::expr_kind::modulus
) == std::string("%"));
91 yap::op_string(yap::expr_kind::multiplies_assign
) ==
94 yap::op_string(yap::expr_kind::divides_assign
) ==
97 yap::op_string(yap::expr_kind::modulus_assign
) ==
101 yap::op_string(yap::expr_kind::plus_assign
) == std::string("+="));
103 yap::op_string(yap::expr_kind::minus_assign
) == std::string("-="));
105 yap::op_string(yap::expr_kind::bitwise_and_assign
) ==
108 yap::op_string(yap::expr_kind::bitwise_or_assign
) ==
111 yap::op_string(yap::expr_kind::bitwise_xor_assign
) ==
114 yap::op_string(yap::expr_kind::subscript
) == std::string("[]"));
115 BOOST_CHECK(yap::op_string(yap::expr_kind::if_else
) == std::string("?:"));
116 BOOST_CHECK(yap::op_string(yap::expr_kind::call
) == std::string("()"));
118 yap::op_string(yap::expr_kind(-1)) ==
119 std::string("** ERROR: UNKNOWN OPERATOR! **"));
123 std::ostringstream oss
;
125 bh::tuple
<int> tuple
{i
};
126 yap::detail::print_type(oss
, tuple
);
127 BOOST_CHECK(oss
.str() == "int");
131 std::ostringstream oss
;
133 bh::tuple
<int const> tuple
{i
};
134 yap::detail::print_type(oss
, tuple
);
135 BOOST_CHECK(oss
.str() == "int const");
139 std::ostringstream oss
;
141 bh::tuple
<int &> tuple
{i
};
142 yap::detail::print_type(oss
, tuple
);
143 BOOST_CHECK(oss
.str() == "int &");
147 std::ostringstream oss
;
149 bh::tuple
<int const &> tuple
{i
};
150 yap::detail::print_type(oss
, tuple
);
151 BOOST_CHECK(oss
.str() == "int const &");
155 user_term
<double> unity
{1.0};
157 user_term
<int &&> i
{std::move(i_
)};
159 yap::expr_kind::plus
,
160 bh::tuple
<user_ref
<user_term
<double> &>, user_term
<int &&>>>
161 expr
= unity
+ std::move(i
);
163 yap::expr_kind::plus
,
165 user_ref
<user_term
<double> &>,
167 yap::expr_kind::plus
,
169 user_ref
<user_term
<double> &>,
170 user_term
<int &&>>>>>
171 unevaluated_expr
= unity
+ std::move(expr
);
174 std::ostringstream oss
;
175 yap::print(oss
, unity
);
176 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
181 std::ostringstream oss
;
182 yap::print(oss
, expr
);
183 BOOST_CHECK(oss
.str() == R
"(expr<+>
190 std::ostringstream oss
;
191 yap::print(oss
, unevaluated_expr
);
192 BOOST_CHECK(oss
.str() == R
"(expr<+>
200 user_term
<thing
> a_thing
{bh::make_tuple(thing
{})};
203 std::ostringstream oss
;
204 yap::print(oss
, a_thing
);
205 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
209 user_term
<double> const const_unity
{1.0};
211 yap::expr_kind::plus
,
213 user_ref
<user_term
<double> &>,
214 user_ref
<user_term
<double> const &>>>
215 nonconst_plus_const
= unity
+ const_unity
;
218 std::ostringstream oss
;
219 yap::print(oss
, nonconst_plus_const
);
220 BOOST_CHECK(oss
.str() == R
"(expr<+>
222 term<double>[=1] const &
226 auto nonconst_plus_nonconst_plus_const
= unity
+ nonconst_plus_const
;
229 std::ostringstream oss
;
230 yap::print(oss
, nonconst_plus_nonconst_plus_const
);
231 BOOST_CHECK(oss
.str() == R
"(expr<+>
235 term<double>[=1] const &
239 auto const const_nonconst_plus_const
= nonconst_plus_const
;
240 auto nonconst_plus_nonconst_plus_const_2
=
241 unity
+ const_nonconst_plus_const
;
244 std::ostringstream oss
;
245 yap::print(oss
, nonconst_plus_nonconst_plus_const_2
);
246 BOOST_CHECK(oss
.str() == R
"(expr<+>
250 term<double>[=1] const &
256 term
<double> unity
{1.0};
258 term
<int &&> i
{std::move(i_
)};
260 yap::expr_kind::plus
,
261 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
262 expr
= unity
+ std::move(i
);
264 yap::expr_kind::plus
,
268 yap::expr_kind::plus
,
269 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
270 unevaluated_expr
= unity
+ std::move(expr
);
273 std::ostringstream oss
;
274 yap::print(oss
, unity
);
275 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
280 std::ostringstream oss
;
281 yap::print(oss
, expr
);
282 BOOST_CHECK(oss
.str() == R
"(expr<+>
289 std::ostringstream oss
;
290 yap::print(oss
, unevaluated_expr
);
291 BOOST_CHECK(oss
.str() == R
"(expr<+>
299 term
<thing
> a_thing(thing
{});
302 std::ostringstream oss
;
303 yap::print(oss
, a_thing
);
304 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
308 term
<double> const const_unity
{1.0};
310 yap::expr_kind::plus
,
311 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
312 nonconst_plus_const
= unity
+ const_unity
;
315 std::ostringstream oss
;
316 yap::print(oss
, nonconst_plus_const
);
317 BOOST_CHECK(oss
.str() == R
"(expr<+>
319 term<double>[=1] const &
324 using namespace yap::literals
;
325 std::ostringstream oss
;
326 yap::print(oss
, 1_p
);
327 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
333 term
<double> unity
{1.0};
335 term
<int &&> i
{std::move(i_
)};
337 yap::expr_kind::minus
,
338 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
339 expr
= unity
- std::move(i
);
341 yap::expr_kind::minus
,
345 yap::expr_kind::minus
,
346 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
347 unevaluated_expr
= unity
- std::move(expr
);
350 std::ostringstream oss
;
351 yap::print(oss
, unity
);
352 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
357 std::ostringstream oss
;
358 yap::print(oss
, expr
);
359 BOOST_CHECK(oss
.str() == R
"(expr<->
366 std::ostringstream oss
;
367 yap::print(oss
, unevaluated_expr
);
368 BOOST_CHECK(oss
.str() == R
"(expr<->
376 term
<thing
> a_thing(thing
{});
379 std::ostringstream oss
;
380 yap::print(oss
, a_thing
);
381 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
385 term
<double> const const_unity
{1.0};
387 yap::expr_kind::minus
,
388 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
389 nonconst_minus_const
= unity
- const_unity
;
392 std::ostringstream oss
;
393 yap::print(oss
, nonconst_minus_const
);
394 BOOST_CHECK(oss
.str() == R
"(expr<->
396 term<double>[=1] const &
401 using namespace yap::literals
;
402 std::ostringstream oss
;
403 yap::print(oss
, 1_p
);
404 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
410 term
<double> unity
{1.0};
412 term
<int &&> i
{std::move(i_
)};
414 yap::expr_kind::less
,
415 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
416 expr
= unity
< std::move(i
);
418 yap::expr_kind::less
,
422 yap::expr_kind::less
,
423 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
424 unevaluated_expr
= unity
< std::move(expr
);
427 std::ostringstream oss
;
428 yap::print(oss
, unity
);
429 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
434 std::ostringstream oss
;
435 yap::print(oss
, expr
);
436 BOOST_CHECK(oss
.str() == R
"(expr<<>
443 std::ostringstream oss
;
444 yap::print(oss
, unevaluated_expr
);
445 BOOST_CHECK(oss
.str() == R
"(expr<<>
453 term
<thing
> a_thing(thing
{});
456 std::ostringstream oss
;
457 yap::print(oss
, a_thing
);
458 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
462 term
<double> const const_unity
{1.0};
464 yap::expr_kind::less
,
465 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
466 nonconst_less_const
= unity
< const_unity
;
469 std::ostringstream oss
;
470 yap::print(oss
, nonconst_less_const
);
471 BOOST_CHECK(oss
.str() == R
"(expr<<>
473 term<double>[=1] const &
478 using namespace yap::literals
;
479 std::ostringstream oss
;
480 yap::print(oss
, 1_p
);
481 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
487 term
<double> unity
{1.0};
489 term
<int &&> i
{std::move(i_
)};
491 yap::expr_kind::greater
,
492 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
493 expr
= unity
> std::move(i
);
495 yap::expr_kind::greater
,
499 yap::expr_kind::greater
,
500 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
501 unevaluated_expr
= unity
> std::move(expr
);
504 std::ostringstream oss
;
505 yap::print(oss
, unity
);
506 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
511 std::ostringstream oss
;
512 yap::print(oss
, expr
);
513 BOOST_CHECK(oss
.str() == R
"(expr<>>
520 std::ostringstream oss
;
521 yap::print(oss
, unevaluated_expr
);
522 BOOST_CHECK(oss
.str() == R
"(expr<>>
530 term
<thing
> a_thing(thing
{});
533 std::ostringstream oss
;
534 yap::print(oss
, a_thing
);
535 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
539 term
<double> const const_unity
{1.0};
541 yap::expr_kind::greater
,
542 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
543 nonconst_greater_const
= unity
> const_unity
;
546 std::ostringstream oss
;
547 yap::print(oss
, nonconst_greater_const
);
548 BOOST_CHECK(oss
.str() == R
"(expr<>>
550 term<double>[=1] const &
555 using namespace yap::literals
;
556 std::ostringstream oss
;
557 yap::print(oss
, 1_p
);
558 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
564 term
<double> unity
{1.0};
566 term
<int &&> i
{std::move(i_
)};
568 yap::expr_kind::less_equal
,
569 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
570 expr
= unity
<= std::move(i
);
572 yap::expr_kind::less_equal
,
576 yap::expr_kind::less_equal
,
577 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
578 unevaluated_expr
= unity
<= std::move(expr
);
581 std::ostringstream oss
;
582 yap::print(oss
, unity
);
583 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
588 std::ostringstream oss
;
589 yap::print(oss
, expr
);
590 BOOST_CHECK(oss
.str() == R
"(expr<<=>
597 std::ostringstream oss
;
598 yap::print(oss
, unevaluated_expr
);
599 BOOST_CHECK(oss
.str() == R
"(expr<<=>
607 term
<thing
> a_thing(thing
{});
610 std::ostringstream oss
;
611 yap::print(oss
, a_thing
);
612 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
616 term
<double> const const_unity
{1.0};
618 yap::expr_kind::less_equal
,
619 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
620 nonconst_less_equal_const
= unity
<= const_unity
;
623 std::ostringstream oss
;
624 yap::print(oss
, nonconst_less_equal_const
);
625 BOOST_CHECK(oss
.str() == R
"(expr<<=>
627 term<double>[=1] const &
632 using namespace yap::literals
;
633 std::ostringstream oss
;
634 yap::print(oss
, 1_p
);
635 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
641 term
<double> unity
{1.0};
643 term
<int &&> i
{std::move(i_
)};
645 yap::expr_kind::greater_equal
,
646 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
647 expr
= unity
>= std::move(i
);
649 yap::expr_kind::greater_equal
,
653 yap::expr_kind::greater_equal
,
654 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
655 unevaluated_expr
= unity
>= std::move(expr
);
658 std::ostringstream oss
;
659 yap::print(oss
, unity
);
660 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
665 std::ostringstream oss
;
666 yap::print(oss
, expr
);
667 BOOST_CHECK(oss
.str() == R
"(expr<>=>
674 std::ostringstream oss
;
675 yap::print(oss
, unevaluated_expr
);
676 BOOST_CHECK(oss
.str() == R
"(expr<>=>
684 term
<thing
> a_thing(thing
{});
687 std::ostringstream oss
;
688 yap::print(oss
, a_thing
);
689 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
693 term
<double> const const_unity
{1.0};
695 yap::expr_kind::greater_equal
,
696 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
697 nonconst_greater_equal_const
= unity
>= const_unity
;
700 std::ostringstream oss
;
701 yap::print(oss
, nonconst_greater_equal_const
);
702 BOOST_CHECK(oss
.str() == R
"(expr<>=>
704 term<double>[=1] const &
709 using namespace yap::literals
;
710 std::ostringstream oss
;
711 yap::print(oss
, 1_p
);
712 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
718 term
<double> unity
{1.0};
720 term
<int &&> i
{std::move(i_
)};
722 yap::expr_kind::equal_to
,
723 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
724 expr
= unity
== std::move(i
);
726 yap::expr_kind::equal_to
,
730 yap::expr_kind::equal_to
,
731 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
732 unevaluated_expr
= unity
== std::move(expr
);
735 std::ostringstream oss
;
736 yap::print(oss
, unity
);
737 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
742 std::ostringstream oss
;
743 yap::print(oss
, expr
);
744 BOOST_CHECK(oss
.str() == R
"(expr<==>
751 std::ostringstream oss
;
752 yap::print(oss
, unevaluated_expr
);
753 BOOST_CHECK(oss
.str() == R
"(expr<==>
761 term
<thing
> a_thing(thing
{});
764 std::ostringstream oss
;
765 yap::print(oss
, a_thing
);
766 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
770 term
<double> const const_unity
{1.0};
772 yap::expr_kind::equal_to
,
773 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
774 nonconst_equal_to_const
= unity
== const_unity
;
777 std::ostringstream oss
;
778 yap::print(oss
, nonconst_equal_to_const
);
779 BOOST_CHECK(oss
.str() == R
"(expr<==>
781 term<double>[=1] const &
786 using namespace yap::literals
;
787 std::ostringstream oss
;
788 yap::print(oss
, 1_p
);
789 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
795 term
<double> unity
{1.0};
797 term
<int &&> i
{std::move(i_
)};
799 yap::expr_kind::not_equal_to
,
800 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
801 expr
= unity
!= std::move(i
);
803 yap::expr_kind::not_equal_to
,
807 yap::expr_kind::not_equal_to
,
808 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
809 unevaluated_expr
= unity
!= std::move(expr
);
812 std::ostringstream oss
;
813 yap::print(oss
, unity
);
814 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
819 std::ostringstream oss
;
820 yap::print(oss
, expr
);
821 BOOST_CHECK(oss
.str() == R
"(expr<!=>
828 std::ostringstream oss
;
829 yap::print(oss
, unevaluated_expr
);
830 BOOST_CHECK(oss
.str() == R
"(expr<!=>
838 term
<thing
> a_thing(thing
{});
841 std::ostringstream oss
;
842 yap::print(oss
, a_thing
);
843 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
847 term
<double> const const_unity
{1.0};
849 yap::expr_kind::not_equal_to
,
850 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
851 nonconst_not_equal_to_const
= unity
!= const_unity
;
854 std::ostringstream oss
;
855 yap::print(oss
, nonconst_not_equal_to_const
);
856 BOOST_CHECK(oss
.str() == R
"(expr<!=>
858 term<double>[=1] const &
863 using namespace yap::literals
;
864 std::ostringstream oss
;
865 yap::print(oss
, 1_p
);
866 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
872 term
<double> unity
{1.0};
874 term
<int &&> i
{std::move(i_
)};
876 yap::expr_kind::logical_or
,
877 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
878 expr
= unity
|| std::move(i
);
880 yap::expr_kind::logical_or
,
884 yap::expr_kind::logical_or
,
885 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
886 unevaluated_expr
= unity
|| std::move(expr
);
889 std::ostringstream oss
;
890 yap::print(oss
, unity
);
891 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
896 std::ostringstream oss
;
897 yap::print(oss
, expr
);
898 BOOST_CHECK(oss
.str() == R
"(expr<||>
905 std::ostringstream oss
;
906 yap::print(oss
, unevaluated_expr
);
907 BOOST_CHECK(oss
.str() == R
"(expr<||>
915 term
<thing
> a_thing(thing
{});
918 std::ostringstream oss
;
919 yap::print(oss
, a_thing
);
920 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
924 term
<double> const const_unity
{1.0};
926 yap::expr_kind::logical_or
,
927 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
928 nonconst_logical_or_const
= unity
|| const_unity
;
931 std::ostringstream oss
;
932 yap::print(oss
, nonconst_logical_or_const
);
933 BOOST_CHECK(oss
.str() == R
"(expr<||>
935 term<double>[=1] const &
940 using namespace yap::literals
;
941 std::ostringstream oss
;
942 yap::print(oss
, 1_p
);
943 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
949 term
<double> unity
{1.0};
951 term
<int &&> i
{std::move(i_
)};
953 yap::expr_kind::logical_and
,
954 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
955 expr
= unity
&& std::move(i
);
957 yap::expr_kind::logical_and
,
961 yap::expr_kind::logical_and
,
962 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
963 unevaluated_expr
= unity
&& std::move(expr
);
966 std::ostringstream oss
;
967 yap::print(oss
, unity
);
968 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
973 std::ostringstream oss
;
974 yap::print(oss
, expr
);
975 BOOST_CHECK(oss
.str() == R
"(expr<&&>
982 std::ostringstream oss
;
983 yap::print(oss
, unevaluated_expr
);
984 BOOST_CHECK(oss
.str() == R
"(expr<&&>
992 term
<thing
> a_thing(thing
{});
995 std::ostringstream oss
;
996 yap::print(oss
, a_thing
);
997 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1001 term
<double> const const_unity
{1.0};
1003 yap::expr_kind::logical_and
,
1004 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1005 nonconst_logical_and_const
= unity
&& const_unity
;
1008 std::ostringstream oss
;
1009 yap::print(oss
, nonconst_logical_and_const
);
1010 BOOST_CHECK(oss
.str() == R
"(expr<&&>
1012 term<double>[=1] const &
1017 using namespace yap::literals
;
1018 std::ostringstream oss
;
1019 yap::print(oss
, 1_p
);
1020 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1026 term
<double> unity
{1.0};
1028 term
<int &&> i
{std::move(i_
)};
1030 yap::expr_kind::bitwise_and
,
1031 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1032 expr
= unity
& std::move(i
);
1034 yap::expr_kind::bitwise_and
,
1036 ref
<term
<double> &>,
1038 yap::expr_kind::bitwise_and
,
1039 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1040 unevaluated_expr
= unity
& std::move(expr
);
1043 std::ostringstream oss
;
1044 yap::print(oss
, unity
);
1045 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1050 std::ostringstream oss
;
1051 yap::print(oss
, expr
);
1052 BOOST_CHECK(oss
.str() == R
"(expr<&>
1059 std::ostringstream oss
;
1060 yap::print(oss
, unevaluated_expr
);
1061 BOOST_CHECK(oss
.str() == R
"(expr<&>
1069 term
<thing
> a_thing(thing
{});
1072 std::ostringstream oss
;
1073 yap::print(oss
, a_thing
);
1074 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1078 term
<double> const const_unity
{1.0};
1080 yap::expr_kind::bitwise_and
,
1081 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1082 nonconst_bitwise_and_const
= unity
& const_unity
;
1085 std::ostringstream oss
;
1086 yap::print(oss
, nonconst_bitwise_and_const
);
1087 BOOST_CHECK(oss
.str() == R
"(expr<&>
1089 term<double>[=1] const &
1094 using namespace yap::literals
;
1095 std::ostringstream oss
;
1096 yap::print(oss
, 1_p
);
1097 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1103 term
<double> unity
{1.0};
1105 term
<int &&> i
{std::move(i_
)};
1107 yap::expr_kind::bitwise_or
,
1108 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1109 expr
= unity
| std::move(i
);
1111 yap::expr_kind::bitwise_or
,
1113 ref
<term
<double> &>,
1115 yap::expr_kind::bitwise_or
,
1116 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1117 unevaluated_expr
= unity
| std::move(expr
);
1120 std::ostringstream oss
;
1121 yap::print(oss
, unity
);
1122 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1127 std::ostringstream oss
;
1128 yap::print(oss
, expr
);
1129 BOOST_CHECK(oss
.str() == R
"(expr<|>
1136 std::ostringstream oss
;
1137 yap::print(oss
, unevaluated_expr
);
1138 BOOST_CHECK(oss
.str() == R
"(expr<|>
1146 term
<thing
> a_thing(thing
{});
1149 std::ostringstream oss
;
1150 yap::print(oss
, a_thing
);
1151 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1155 term
<double> const const_unity
{1.0};
1157 yap::expr_kind::bitwise_or
,
1158 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1159 nonconst_bitwise_or_const
= unity
| const_unity
;
1162 std::ostringstream oss
;
1163 yap::print(oss
, nonconst_bitwise_or_const
);
1164 BOOST_CHECK(oss
.str() == R
"(expr<|>
1166 term<double>[=1] const &
1171 using namespace yap::literals
;
1172 std::ostringstream oss
;
1173 yap::print(oss
, 1_p
);
1174 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1180 term
<double> unity
{1.0};
1182 term
<int &&> i
{std::move(i_
)};
1184 yap::expr_kind::bitwise_xor
,
1185 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1186 expr
= unity
^ std::move(i
);
1188 yap::expr_kind::bitwise_xor
,
1190 ref
<term
<double> &>,
1192 yap::expr_kind::bitwise_xor
,
1193 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1194 unevaluated_expr
= unity
^ std::move(expr
);
1197 std::ostringstream oss
;
1198 yap::print(oss
, unity
);
1199 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1204 std::ostringstream oss
;
1205 yap::print(oss
, expr
);
1206 BOOST_CHECK(oss
.str() == R
"(expr<^>
1213 std::ostringstream oss
;
1214 yap::print(oss
, unevaluated_expr
);
1215 BOOST_CHECK(oss
.str() == R
"(expr<^>
1223 term
<thing
> a_thing(thing
{});
1226 std::ostringstream oss
;
1227 yap::print(oss
, a_thing
);
1228 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1232 term
<double> const const_unity
{1.0};
1234 yap::expr_kind::bitwise_xor
,
1235 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1236 nonconst_bitwise_xor_const
= unity
^ const_unity
;
1239 std::ostringstream oss
;
1240 yap::print(oss
, nonconst_bitwise_xor_const
);
1241 BOOST_CHECK(oss
.str() == R
"(expr<^>
1243 term<double>[=1] const &
1248 using namespace yap::literals
;
1249 std::ostringstream oss
;
1250 yap::print(oss
, 1_p
);
1251 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1257 term
<double> unity
{1.0};
1259 term
<int &&> i
{std::move(i_
)};
1261 yap::expr_kind::comma
,
1262 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1263 expr
= (unity
, std::move(i
));
1265 yap::expr_kind::comma
,
1267 ref
<term
<double> &>,
1269 yap::expr_kind::comma
,
1270 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1271 unevaluated_expr
= (unity
, std::move(expr
));
1274 std::ostringstream oss
;
1275 yap::print(oss
, unity
);
1276 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1281 std::ostringstream oss
;
1282 yap::print(oss
, expr
);
1283 BOOST_CHECK(oss
.str() == R
"(expr<,>
1290 std::ostringstream oss
;
1291 yap::print(oss
, unevaluated_expr
);
1292 BOOST_CHECK(oss
.str() == R
"(expr<,>
1300 term
<thing
> a_thing(thing
{});
1303 std::ostringstream oss
;
1304 yap::print(oss
, a_thing
);
1305 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1309 term
<double> const const_unity
{1.0};
1311 yap::expr_kind::comma
,
1312 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1313 nonconst_comma_const
= (unity
, const_unity
);
1316 std::ostringstream oss
;
1317 yap::print(oss
, nonconst_comma_const
);
1318 BOOST_CHECK(oss
.str() == R
"(expr<,>
1320 term<double>[=1] const &
1325 using namespace yap::literals
;
1326 std::ostringstream oss
;
1327 yap::print(oss
, 1_p
);
1328 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1334 term
<double> unity
{1.0};
1336 term
<int &&> i
{std::move(i_
)};
1338 yap::expr_kind::mem_ptr
,
1339 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1340 expr
= unity
->*std::move(i
);
1342 yap::expr_kind::mem_ptr
,
1344 ref
<term
<double> &>,
1346 yap::expr_kind::mem_ptr
,
1347 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1348 unevaluated_expr
= unity
->*std::move(expr
);
1351 std::ostringstream oss
;
1352 yap::print(oss
, unity
);
1353 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1358 std::ostringstream oss
;
1359 yap::print(oss
, expr
);
1360 BOOST_CHECK(oss
.str() == R
"(expr<->*>
1367 std::ostringstream oss
;
1368 yap::print(oss
, unevaluated_expr
);
1369 BOOST_CHECK(oss
.str() == R
"(expr<->*>
1377 term
<thing
> a_thing(thing
{});
1380 std::ostringstream oss
;
1381 yap::print(oss
, a_thing
);
1382 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1386 term
<double> const const_unity
{1.0};
1388 yap::expr_kind::mem_ptr
,
1389 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1390 nonconst_mem_ptr_const
= unity
->*const_unity
;
1393 std::ostringstream oss
;
1394 yap::print(oss
, nonconst_mem_ptr_const
);
1395 BOOST_CHECK(oss
.str() == R
"(expr<->*>
1397 term<double>[=1] const &
1402 using namespace yap::literals
;
1403 std::ostringstream oss
;
1404 yap::print(oss
, 1_p
);
1405 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1411 term
<double> unity
{1.0};
1413 term
<int &&> i
{std::move(i_
)};
1415 yap::expr_kind::assign
,
1416 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1417 expr
= unity
= std::move(i
);
1419 yap::expr_kind::assign
,
1421 ref
<term
<double> &>,
1423 yap::expr_kind::assign
,
1424 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1425 unevaluated_expr
= unity
= std::move(expr
);
1428 std::ostringstream oss
;
1429 yap::print(oss
, unity
);
1430 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1435 std::ostringstream oss
;
1436 yap::print(oss
, expr
);
1437 BOOST_CHECK(oss
.str() == R
"(expr<=>
1444 std::ostringstream oss
;
1445 yap::print(oss
, unevaluated_expr
);
1446 BOOST_CHECK(oss
.str() == R
"(expr<=>
1454 term
<thing
> a_thing(thing
{});
1457 std::ostringstream oss
;
1458 yap::print(oss
, a_thing
);
1459 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1464 using namespace yap::literals
;
1465 std::ostringstream oss
;
1466 yap::print(oss
, 1_p
);
1467 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1473 term
<double> unity
{1.0};
1475 term
<int &&> i
{std::move(i_
)};
1477 yap::expr_kind::shift_left_assign
,
1478 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1479 expr
= unity
<<= std::move(i
);
1481 yap::expr_kind::shift_left_assign
,
1483 ref
<term
<double> &>,
1485 yap::expr_kind::shift_left_assign
,
1486 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1487 unevaluated_expr
= unity
<<= std::move(expr
);
1490 std::ostringstream oss
;
1491 yap::print(oss
, unity
);
1492 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1497 std::ostringstream oss
;
1498 yap::print(oss
, expr
);
1499 BOOST_CHECK(oss
.str() == R
"(expr<<<=>
1506 std::ostringstream oss
;
1507 yap::print(oss
, unevaluated_expr
);
1508 BOOST_CHECK(oss
.str() == R
"(expr<<<=>
1516 term
<thing
> a_thing(thing
{});
1519 std::ostringstream oss
;
1520 yap::print(oss
, a_thing
);
1521 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1525 term
<double> const const_unity
{1.0};
1527 yap::expr_kind::shift_left_assign
,
1528 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1529 nonconst_shift_left_assign_const
= unity
<<= const_unity
;
1532 std::ostringstream oss
;
1533 yap::print(oss
, nonconst_shift_left_assign_const
);
1534 BOOST_CHECK(oss
.str() == R
"(expr<<<=>
1536 term<double>[=1] const &
1541 using namespace yap::literals
;
1542 std::ostringstream oss
;
1543 yap::print(oss
, 1_p
);
1544 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1550 term
<double> unity
{1.0};
1552 term
<int &&> i
{std::move(i_
)};
1554 yap::expr_kind::shift_right_assign
,
1555 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>
1556 expr
= unity
>>= std::move(i
);
1558 yap::expr_kind::shift_right_assign
,
1560 ref
<term
<double> &>,
1562 yap::expr_kind::shift_right_assign
,
1563 bh::tuple
<ref
<term
<double> &>, term
<int &&>>>>>
1564 unevaluated_expr
= unity
>>= std::move(expr
);
1567 std::ostringstream oss
;
1568 yap::print(oss
, unity
);
1569 BOOST_CHECK(oss
.str() == R
"(term<double>[=1]
1574 std::ostringstream oss
;
1575 yap::print(oss
, expr
);
1576 BOOST_CHECK(oss
.str() == R
"(expr<>>=>
1583 std::ostringstream oss
;
1584 yap::print(oss
, unevaluated_expr
);
1585 BOOST_CHECK(oss
.str() == R
"(expr<>>=>
1593 term
<thing
> a_thing(thing
{});
1596 std::ostringstream oss
;
1597 yap::print(oss
, a_thing
);
1598 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<thing>[=<<unprintable-value>>]
1602 term
<double> const const_unity
{1.0};
1604 yap::expr_kind::shift_right_assign
,
1605 bh::tuple
<ref
<term
<double> &>, ref
<term
<double> const &>>>
1606 nonconst_shift_right_assign_const
= unity
>>= const_unity
;
1609 std::ostringstream oss
;
1610 yap::print(oss
, nonconst_shift_right_assign_const
);
1611 BOOST_CHECK(oss
.str() == R
"(expr<>>=>
1613 term<double>[=1] const &
1618 using namespace yap::literals
;
1619 std::ostringstream oss
;
1620 yap::print(oss
, 1_p
);
1621 BOOST_CHECK(fix_tti(oss
.str()) == R
"(term<boost::yap::placeholder<1>>[=1]
1627 using namespace yap::literals
;
1628 std::ostringstream oss
;
1629 yap::print(oss
, replace_placeholders(1_p
+ 2_p
,7,8));
1630 BOOST_CHECK(fix_tti(oss
.str()) == R
"(expr<+>