|
Boost : |
Subject: [boost] [Iterator] Constness of transform_iterator's function call operator
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-05-24 05:05:27
A long-standing request that transform_iterator should use boost::result_of
will be resolved in Boost 1.47. This is really nice news,
but I have a concern related to this.
In the new code, transform_iterator uses
result_of<UnaryFunc(typename std::iterator_traits<Iterator>::reference)>
to determine the return type of a functor.
However, since transform_iterator's function call operator is const,
result_of<const UnaryFunc(typename std::iterator_traits<Iterator>::reference)>
should be used instead.
There is a patch for this fix in #5127:
https://svn.boost.org/trac/boost/ticket/5127
Alternatively, to remove this inconsistency, we can strip the constness of
transform_iterator's function call operator by either
A. Make UnaryFunc member data mutable as suggested in #4969:
https://svn.boost.org/trac/boost/ticket/4969
or
B. Add non-const overloads to
- transform_iterator's dereference
- iterator_core_access' dereference
- iterator_facade's operator()
Patches for A (make_mutable.patch) and B (add_nonconst_overloads.patch)
are attached in this mail.
Comments?
Regards,
Michel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk