Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::transform_iterator and C++0x decltype
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-02-23 03:32:49


Hi Nathan,

Nathan Ridge wrote:
> Currently (boost 1.46) boost::transform_iterator requires that the unary
> functor 'f' passed to it use the 'result_of' protocol to declare its
> return type (that is, it must either have a nested 'result_type' typedef,
> or in the case of polymorphic functions, a nested 'result' metafunction
> that computes the return type given the parameter type).

FYI, boost::transform_iterator in Boost 1.46 detects `result_type`
nested-type, but it does not support `result_of` protocol. This is
planned to be fixed in Boost 1.47.
See the following ticket:
https://svn.boost.org/trac/boost/ticket/1427

> Would it be a good idea to modify the requirements so that if
> the boost library detects C++0x support, it uses 'decltype' to
> determine the return type of the functor, so that the functor
> does not have to use the 'result_of' protocol?

By defining BOOST_RESULT_OF_USE_DECLTYPE (and if the compiler supports
`decltype` functionality), boost::result_of uses `decltype` to determine
the return type.
You can find this info in `result_of` documentation:
http://www.boost.org/doc/libs/1_45_0/libs/utility/utility.htm#result_of

So your proposal can be simply achieved by defining BOOST_RESULT_OF_USE_DECLTYPE
before including transform_iterator.hpp.

Regards,
Michel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net