The following message is a courtesy copy of an article that has been posted to comp.lang.c++.moderated as well. lotusny78@yahoo.com writes:
Is there an "easy" way to pass iterators by reference to STL Algorithms? By easy, I mean not more complicated than using a for loop.
e.g. typedef set<int>::const_iterator cIterType; cIterType bit = mySet.begin(); cIterType eit = mySet.end();
for_each(ref(bit), ref(eit), if_(bind(boost::next<cIterType>, boost::ref(bit)) != mySet.end()) [...] );
The code above, using boost::ref does not compile, at least in part because boost::reference_wrapper does not contain some STL typedefs.
If anyone has any ideas, I'd appreciate them. Thanks.
This is clearly (to me, but probably not to most other readers of this NG) a Boost.Lambda - related question. If you post it to an appropriate mailing list (see http://www.boost.org/more/mailing_lists.htm) you'll probably get more useful answers. HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com