boost::transform_iterator and C++0x decltype
Hello, 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). 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? I would be happy to contribute a patch implementing this. Regards, Nate.
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
participants (2)
-
Michel MORIN
-
Nathan Ridge