2
0
mirror of https://github.com/boostorg/yap.git synced 2026-02-26 17:22:10 +00:00

Flesh out Transform Matching section.

This commit is contained in:
Zach Laine
2016-12-13 23:39:14 -06:00
parent 07f4512320
commit 3c39a117b8
4 changed files with 90 additions and 7 deletions

View File

@@ -221,19 +221,31 @@ namespace user {
// ternary transforms
//[ tag_xform
struct ternary_to_else_xform_tag
{
template <typename Expr>
decltype(auto) operator() (yap::if_else_tag, Expr const & cond, user::number const & then, user::number const & else_)
{ return yap::make_terminal(else_); }
decltype(auto) operator() (
boost::yap::if_else_tag,
Expr const & cond,
user::number const & then,
user::number const & else_
) { return boost::yap::make_terminal(else_); }
};
//]
//[ expr_xform
struct ternary_to_else_xform_expr
{
template <typename Cond, typename Then, typename Else>
decltype(auto) operator() (yap::expression<yap::expr_kind::if_else, bh::tuple<Cond, Then, Else>> const & expr)
{ return ::boost::yap::else_(expr); }
decltype(auto) operator() (
boost::yap::expression<
boost::yap::expr_kind::if_else,
boost::hana::tuple<Cond, Then, Else>
> const & expr
) { return ::boost::yap::else_(expr); }
};
//]
struct ternary_to_else_xform_both
{