Boost logo

Boost Users :

Subject: [Boost-users] returning range adaptor generator
From: Nick Stokes (randomaccessiterator_at_[hidden])
Date: 2013-10-01 16:21:24


What should be the return type for a function that returns an adapted
range? E.g.

template<class Range>
xxx getIndirected( const Range& r ) {
   return r | boost::adaptors::indirected;
}

The use case being, providing a API with these little useful helpers
without forcing the user to know about Boost.Range at all. Like so:

#include <myapi.hpp>
#include <boost/foreach.hpp>

LegacyPointerContainers f; // contains Foo pointers

BOOST_FOREACH( Foo& f, TraverseFoo( f ) ) {

}

/// where in myapi.hpp

xxx TraverseFoo( LegacyPointerContainers& f ) { return getIndirected(
makeRange(f) ) ; }

PS: This is all C++03. No autos.

Thanks

Nick



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