Boost logo

Boost :

Subject: Re: [boost] [Proto][Phoenix] Use default transform with SFINAE for expressions?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-09-12 08:11:35


On 12/09/2010 09:18, Thomas Heller wrote:

> Phoenix3 uses result_of protocol, and result_type wherever the return type
> is monomorphic.

It uses result_of on the grammar, which in turns calls apply_transform
on the default transform, the latter not happening in a template
deduction context and thus preventing SFINAE to happen.

>
> My take would be to use boost::result_of<Expr(T1, T2, ...)>::type before
> calling the phoenix expression and use SFINAE here.

I don't understand what you mean, and how that would help at all.

What needs to be in an SFINAE context, here, is something of the kind
decltype(make_mutable<T0>() << make_mutable<T1>()), with T0 and T1
template parameters.

If you try the above code, you'll get an error in the default_shift_left
transform, which already uses decltype to deduce the return type, but
not in a template context.
If you change default_shift_left's operator() to be a template and
change its result type deduction to be in a template context as well,
then you get an error that says no overload matches within
default_shift_left. That's because the SFINAE doesn't propagate up to
the grammar through apply_transform etc., and making that work involves
doing the changes that I said.

It's really a limitation in Proto at this point, not in Phoenix.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk