[ANN] range algorithms and adaptors

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

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
participants (2)
-
Eric Niebler
-
Thorsten Ottosen