|
Boost : |
Subject: [boost] [Iterator] Constness of transform_iterator's dereference operator
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-05-24 19:27:26
(In the previous mail, "function call operator" should be
"dereference operator". Sorry for this, I fix it and resend a mail.)
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 dereference 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 dereference 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() function
- iterator_core_access' dereference() function
- 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