I needed this again so I had a second look. There is a way to concat two ranges using boost/range/join.hpp. Unluckily the output range type is not included in the interface:
#include "boost/range/join.hpp"
#include "boost/foreach.hpp"
#include <iostream>
int main() {
int a[] = {1, 2, 3, 4};
int b[] = {7, 2, 3, 4};
boost::iterator_range<int*> ai(&a[0], &a[4]);
boost::iterator_range<int*> bi(&b[0], &b[4]);
boost::iterator_range<
boost::range_detail::
join_iterator<int*, int*, int, int&,
boost::random_access_traversal_tag> > ci = boost::join(ai, bi);
BOOST_FOREACH(int& i, ci) {
std::cout << i; //prints 12347234
}
}
I found the output type using the compiler messages. C++0x auto
will be relevant there as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…