Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-01-27 09:07:00


Hi Eric,

| 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';
| }

Sorry fot the late reply. Anyway, I just wanted to
say that the pipe opertor seems to work really well at reducing
the syntax overhead of

filtered( indirected( widgets ), ... )

style range construction.

br

Thorsten


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