Opened 15 years ago
Closed 12 years ago
#1427 closed Feature Requests (fixed)
[iterator] transform_iterator should use boost::result_of to determine functor result type
Reported by: | anonymous | Owned by: | Dave Abrahams |
---|---|---|---|
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 (4)
Change History (15)
by , 13 years ago
Attachment: | patch_transform_iterator added |
---|
by , 13 years ago
Attachment: | patch_transform_iterator_test added |
---|
transform_iterator_test.cpp patch for boost 1.39
comment:1 by , 13 years ago
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 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopened, until merged to release.
comment:4 by , 12 years ago
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:6 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
r67792 does not seem to do anything with transform_iterator.hpp. Is there something missing?
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:8 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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 theresult_of
protocol thanvalue_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.
by , 12 years ago
Attachment: | transform_iterator.patch added |
---|
A patch against trunk (boost/iterator/transform_iterator.hpp)
by , 12 years ago
Attachment: | transform_iterator_test.patch added |
---|
A patch against trunk (libs/iterator/test/transform_iterator_test.cpp)
comment:10 by , 12 years ago
comment:11 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
transform_iterator.hpp patch for boost 1.39