Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2005-03-01 09:23:59


Andy Little wrote:
> "Jonathan Turkanis" <technews_at_[hidden]> wrote in message
> news:cvvvpc$ipt$1_at_sea.gmane.org...
>
>>Andy Little wrote:
>>
>>>>From what I have seen its very cool. :-)

Glad you like it !

>>>
>>>How does this play with boost::result_of. Is there any potential to
>>>extend result_of by this?
>>
>>result_of should already get the right answers for these types.
>

There's a different intention behind result_of (as it detects the result
of a Functor concept, given that functor classes have a result_type member.

This library, in contrast, is about working with function types (making
it work on functors would be in some ways similar to making
remove_pointer work on smart pointers).

This library (once it is in stable state) could be used to implement
result_of, I believe.

>
> #include <iostream>
> #include "boost/utility/result_of.hpp" // v 1.32.0
>
> // BTW following requires #include
> "boost/function_types/function_type_parameter.hpp"
> #include "boost/function_types/function_type_result.hpp"
>

Oh nice, another typo. Fixed, now - thanks for detecting !

(
   this line: using function_types::function_type_parameter;
   should be: using function_types::function_type_result;
   in function_type_result.hpp
)

> [...code...]

Assumed the bug above is fixed, this code should compile:

#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

#include <boost/utility/result_of.hpp>
#include <boost/function_types/function_type_result.hpp>

typedef int (*f)(int); // result_of needs ref/ptr to function to work

using namespace boost;

BOOST_MPL_ASSERT((is_same<
   function_type_result<f>::type
, result_of< f(int) >::type // see http://www.tinyurl.com/6a87k
>));

Regards,

Tobias


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