er wrote:
I am wondering if perhaps someone responsible for range_ex has
implemented concat and would care to kindly share it (apparently it's
not included in the vault).
Someone tells me I overlooked chain which works similarly, albeit for
single pass only. Very useful, thanks!
#include <iostream>
#include <vector>
#include <list>
#include <iterator>
#include <algorithm>
#include
#include
#include
#include
int main (int argc, char * const argv[]) {
typedef double val_;
typedef std::vector vec_;
typedef std::list list_;
vec_ seq0; seq0.push_back(1);
list_ seq1; seq1.push_back(2);
vec_ seq2; seq2.push_back(3); seq2.push_back(4);
vec_ seq3; seq2.push_back(5);
BOOST_AUTO(
chained,
boost::chain(seq0,
boost::chain(seq1,
boost::chain(seq2,seq3)
)
)
);
BOOST_ASSERT( *boost::begin(chained) == 1 ); // Warning : reference to
temporary
BOOST_ASSERT( *boost::next(boost::begin(chained),1) == 2);
BOOST_ASSERT( *boost::next(boost::begin(chained),2) == 3);
BOOST_ASSERT( *boost::next(boost::begin(chained),3) == 4);
BOOST_ASSERT( *boost::next(boost::begin(chained),4) == 5);
std::copy(
boost::begin(chained),
boost::end(chained),
std::ostream_iterator(std::cout, " ")
);
return 0;
}