Modify

Ticket #1427 (closed Feature Requests: fixed)

Opened 6 years ago

Last modified 3 years ago

[iterator] transform_iterator should use boost::result_of to determine functor result type

Reported by: anonymous Owned by: dave
Milestone: To Be Determined Component: iterator
Version: Boost 1.34.1 Severity: Problem
Keywords: transform_iterator result_of Cc:

Description

transform_iterator should use boost::result_of to determine result type of functor instead of nested result_type.

Attachments

patch_transform_iterator Download (2.0 KB) - added by debionne@… 5 years ago.
transform_iterator.hpp patch for boost 1.39
patch_transform_iterator_test Download (1.5 KB) - added by debionne@… 5 years ago.
transform_iterator_test.cpp patch for boost 1.39
transform_iterator.patch Download (770 bytes) - added by mimomorin@… 3 years ago.
A patch against trunk (boost/iterator/transform_iterator.hpp)
transform_iterator_test.patch Download (816 bytes) - added by mimomorin@… 3 years ago.
A patch against trunk (libs/iterator/test/transform_iterator_test.cpp)

Change History

Changed 5 years ago by debionne@…

transform_iterator.hpp patch for boost 1.39

Changed 5 years ago by debionne@…

transform_iterator_test.cpp patch for boost 1.39

comment:1 Changed 5 years ago by debionne@…

The patchs above changes the mechanism that computes the default result type of the given UnaryFunction? to use boost::result_of. Consequently, transform_iterator now support polymorphic object function (i.e. function wich result type depends on the arguments type). Such a function object must implement the result_of 'protocol', that is implement a nested result structure such as :

template <class FArgs> struct result; template <class F, class T> struct result<F(T)> {typedef whatever<T>::type type};

A polymorphic object function is added to the tests.

comment:2 Changed 4 years ago by jewillco

  • Status changed from new to closed
  • Resolution set to fixed

(In [62625]) Applied patches from #1427; fixes #1427

comment:3 Changed 3 years ago by mimomorin@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

Reopened, until merged to release.

comment:4 Changed 3 years ago by marshall

(In [67792]) Merging fixes to release; fixes #2294 fixes #4918 fixes #3645 refs #2823 refs #1427 refs #2893

comment:5 Changed 3 years ago by marshall

  • Status changed from reopened to closed
  • Resolution set to fixed

comment:6 Changed 3 years ago by mimomorin@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

r67792 does not seem to do anything with transform_iterator.hpp. Is there something missing?

comment:7 Changed 3 years ago by marshall

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [68076]) Merging fixes to release; Fixes #1427

comment:8 Changed 3 years ago by mimomorin@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

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.

Changed 3 years ago by mimomorin@…

A patch against trunk (boost/iterator/transform_iterator.hpp)

Changed 3 years ago by mimomorin@…

A patch against trunk (libs/iterator/test/transform_iterator_test.cpp)

comment:9 Changed 3 years ago by marshall

I've committed these patches as [68205]

comment:10 Changed 3 years ago by danieljames

(In [68524]) Revert [68076], refs #1427.

Will try to fix this properly in 1.47.

comment:11 Changed 3 years ago by danieljames

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [70715]) Iterator: Use boost::result_of to determine nested result type of function in transform_iterator. Fixes #1427.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.