From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-07-02 16:17:00
On Wed, Jul 2, 2008 at 8:40 PM, Eric Niebler <eric_at_[hidden]> wrote:
> David Abrahams wrote:
>> Eric Niebler wrote:
>>> David Abrahams wrote:
>>>> Eric Niebler wrote:
>>>>> The Phoenix/Proto port in (Phoenix v3) uses BOOST_TYPEOF to deduce the
>>>>> the type of expressions involving operators, with the exception of the
>>>>> function call operator. For the function call operator, Phoenix v3 uses
>>>>> result_of to calculate the return type.
>>>> Interesting. Kinda makes sense, but could you explain the rationale
>>> You mean, the rationale for using result_of instead of BOOST_TYPEOF for
>>> the function call operator? BOOST_TYPEOF can't perfectly distinguish
>>> between lvalues and rvalues. I fudge it where I have to, but with
>>> function calls no fudging is necessary because result_of presumably
>>> gives the right answer.
>> Assuming it's implemented, yeah. It might be nice to be able to fudge
>> when it isn't :-)
> I don't know a sufficiently portable way to ask a type whether it has
> implemented the result_of protocol. In C++0x, result_of will simply use
> decltype, so at the very least Phoenix's approach is forward-compatible.
With 'portable' you mean 'works with non completely compliant compilers'?
Otherwise I think you can legally sfinae on the presence of both
result<> and result_type.