Re: [Boost-bugs] [Boost C++ Libraries] #1427: [iterator] transform_iterator should use boost::result_of to determine functor result type

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1427: [iterator] transform_iterator should use boost::result_of to determine functor result type
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-01-17 13:03:27


#1427: [iterator] transform_iterator should use boost::result_of to determine
functor result type
-------------------------------+--------------------------------------------
  Reporter: anonymous | Owner: dave
      Type: Feature Requests | Status: reopened
 Milestone: To Be Determined | Component: iterator
   Version: Boost 1.34.1 | Severity: Problem
Resolution: | Keywords: transform_iterator result_of
-------------------------------+--------------------------------------------
Changes (by mimomorin@…):

  * status: closed => reopened
  * resolution: fixed =>

Comment:

 I've experimented with the updated `transform_iterator`,
 and found a discrepancy between code and document.

 The document says that the (default) `reference` member of
 `transform_iterator` is
 {{{
 result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type
 }}}
 But the code uses
 {{{
 result_of<UnaryFunction(iterator_traits<Iterator>::value_type)>::type
 }}}

 We should modify the code to use `reference` instead of `value_type`,
 because
  * the discrepancy is confusing for users
  * `reference` better interacts with the `result_of` protocol than
 `value_type`

 The current code in trunk/release causes compiler error in the following
 code:
 {{{
 #include <boost/array.hpp>
 #include <boost/iterator/transform_iterator.hpp>
 #include <boost/spirit/include/phoenix.hpp>

 int main(int argc, char* argv[])
 {
     boost::array<int, 3> ar = {{}};

     *boost::make_transform_iterator(ar.cbegin(),
 boost::phoenix::arg_names::_1);

     return 0;
 }
 }}}
 I will attach a patch for fixing this.

 Sorry for reopening this ticket repeatedly.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/1427#comment:8>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:05 UTC