
John Torjo <john.lists@torjo.com> writes:
It seems to me that, since I know that binding to an rvalue is required, we ought to have a way to say "force this to be a const ref". I thought of something like
std::for_each( make_difference_iterator(p->second.begin()) , make_difference_iterator(p->second.end()) , boost::bind(&fu::writeVInt, &prox, boost::cref(_1)));
How about constifying the original sequence?
That wouldn't help.
Something like:
std::for_each( make_difference_iterator( constify( p->second.begin())) , make_difference_iterator( constify( p->second.end())) , boost::bind(&fu::writeVInt, &prox, boost::cref(_1)));
Of course, constify it's just too easy to implement:
template<class T> const T& constify(T &val) { return val; }
The problem is that dereferencing a difference_iterator yields an rvalue. -- Dave Abrahams Boost Consulting www.boost-consulting.com