// Boost.Range adaptors
//
// tested with Boost 1.46.1
#include <boost/lambda/lambda.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/counting_range.hpp>
#include <iostream>
#include <vector>
using namespace std;
using namespace boost;
using namespace boost::adaptors;
using namespace boost::lambda;
int main()
{
vector<int> s;
// see "List comprehension" in Wikipedia: s = [ 2*x | x <- [0..], x^2 > 3 ]
push_back(s,
counting_range(0,11) | filtered( _1*_1 > 3 ) | transformed( ret<int>(2*_1) )
);
// print s
copy( s, ostream_iterator<int>(cout, " ") );
}
// the ugly ret<int>() will hopefully go away after switch to Phoenix3.
// Unlike Lambda, it is supposed to support result_of protocol.