Boost logo

Boost :

From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2007-01-06 05:33:02


Peter Dimov wrote:
> AlisdairM wrote:
>> I am a little confused by the result_of tests, which means either I
>> don't understand the library, or there is a problem as most compilers
>> are passing!
>>
>> The basic case:
>>
>> struct int_result_type { typedef int result_type; };
>>
>> BOOST_STATIC_ASSERT
>> ((
>> is_same< result_of< int_result_type(float) >::type, int >::value
>> ));
>>
>>
>> If I understand correctly, this is asking what is the result_of a
>> function taking a float and returning an int_result_type.
>
> No, this is a common misunderstanding of result_of.
>
> result_of<F(X)> asks "what is the return type of f(x), where f is of type F
> and x is of type X?"
>
> So in the above case, it asks what the result would be if we were to create
> an instance of int_result_type and call it with 1.0f.
>
> The correct answer is, of course, "a compile time error", but the TR1 spec
> forces result_of to report 'int' for the usual reasons. :-)

Wouldn't the result_of library be completely useless once typeof and
other stuff like that be introduced into the language? Is the result_of
library just a temporary patch accepted to tr1 only until C++0x? Or
maybe I also didn't understand this library...


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