Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-01-23 20:01:22


I just uploaded to the boost-sandbox a set of range-based algorithms and
adaptors. The algorithms are based on container_algo.hpp from the
sequence_algo library (Thorsten Ottosen, Jeremy Siek, Vladimir Prus). I
have reimplemented them on top of Boost.Range, and changed the modifying
  algorithms to work with ranges that are physically const but logically
non-const (such as std::pair<char*,char*> const).

I have also implemented range adaptors, which are built on top of
Boost.Range and the iterator adaptors in Boost.Iterator. There are
transform, filter, reverse and indirect range adaptors. They combine
with the range algorithms and with BOOST_FOREACH. Consider the following
which takes a list of Widget pointers and finds a Widget which is
visible and that is named "This Widget":

   list<Widget*> widgets = ...;
   list<Widget*>::iterator = find(
       widgets
           | indirect
           | filter(bind(&Widget::Visible,_1))
           | transform(bind(&Widget::Name,_1))
     , "This widget"
   ).base().base().base();

And consider the following, which loops over a vector in reverse order:

   vector<string> strings = ...;
   BOOST_FOREACH( string & str, strings | reverse )
   {
       cout << str << '\n';
   }

The code is in boost-sandbox at boost-sandbox/boost/range_ex. I have
also put a range_ex.zip in the file vault at:
http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler

No docs or tests yet. This is a work in progress. Feedback welcome.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk