Boost logo

Boost :

Subject: Re: [boost] [result_of] Usage guidelines
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2012-09-15 21:07:15


On Sep 12, 2012, at 11:16 AM, Andrey Semashev wrote:

> On Wednesday 12 September 2012 07:31:34 Jeffrey Lee Hellrung, Jr. wrote:
>>
>> Regarding the signature one instantiates result_of with, the present
>> Boost.ResultOf documentation states that result_of< F ( T ) >::type is the
>> result of f(t) where f is an *lvalue* of type F and t is an *lvalue* of
>> type T. I've personally always found this needlessly limiting (precludes
>> deducing strictly correct result types for rvalue arguments), and it
>> appears to contradict what is expressed in this patch. I understand this
>> patch as strictly an addition to the present documentation, so I wonder if
>> it is appropriate to alter the existing Boost.ResultOf documentation text
>> to reflect these "new" usage guidelines (specifically, distinguishing
>> between lvalue and rvalue parameters).
>
> Good catch, I missed that limitation in the formal result_of description.
> Indeed, with the current wording the meaning of result_of<f(int)>::type is
> unclear.
>
> std::result_of<F(T)> is defined in terms of std::declval<T>() which
> effectively means that when T is not a lvalue reference, the argument is
> assumed to be rvalue. This is outlined in the guidelines and I think, the
> formal description should be updated accordingly, unless there are some
> background reasons not to.

The statement regarding the objects being lvalues is from the original documentation and should really only serve as an example these days. I changed that part of the documentation to refer to it as such; i.e. an example not a restrictive definition. I also added a reference to the more formal/explicit decltype(declval<f>()(declval<T>(),...)) expression.

- Daniel


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