|
Boost : |
Subject: Re: [boost] Yap's formal review is starting now!
From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2018-02-16 20:45:00
On Fri, Feb 16, 2018 at 2:28 PM, Steven Watanabe via Boost <
boost_at_[hidden]> wrote:
> AMDG
>
> On 02/16/2018 01:09 PM, Zach Laine via Boost wrote:
> >
> > I'm don't understand what that would mean, exactly. What you can write
> > though is:
> >
> > template <typename Tag, typename... T>
> > auto operator()(Tag, T &&... t)
> >
> > Is that different from the intended use case above?
> >
>
> There's one annoying problem with this, which
> is that it can match an expression transform,
> with Tag as the Expression and T as an empty
> parameter pack.
Very true, and very annoying. I tend to explicitly cover the possible
arities. They are unary, binary, ternary for if_else, and N for call. I'm
certainly open to something that makes transforms easier to write, if you
or Peter have ideas.
In this case, something like the expression_tag<> scheme Peter recommended
helps with this particular ambiguity:
template <typename Tag, typename... T>
auto operator()(expression_tag<Tag>, T &&... t)
{
// and it also seems to help with writing targeted transforms in C++17:
if (yap::to_kind<Tag>() == yap::expr_kind::terminal) {
return yap::transform(yap::as_expr<my_expr>(std::forward<T>(t)));
} else {
return yap::make_expression<yap::to_kind<my_expr,
Tag>()>(std::forward<T>(t)...);
}
}
Zach
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk