Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-04-03 20:55:48


The following message is a courtesy copy of an article
that has been posted to comp.lang.c++.moderated as well.

lotusny78_at_[hidden] 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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net