Boost range library

Below an example of use of the boost range

void testBoostRange()

 

{

using namespace std;

using namespace boost;

using namespace boost::assign;

vector<int> w_workingVec;

// list initializer

push_back(w_workingVec)=8,6,4,4;

print_container(w_workingVec);

// boost range

typedef iterator_range<vector<int>::iterator> boost_irange;

boost_irange new_range =

make_iterator_range( w_workingVec.begin(), w_workingVec.end());

typedef std::iterator_traits<boost_irange::value_type>::distance_type dist_type;

typedef boost::range_value<boost_irange>::typevalue_type; // value that iterator point to

typedef boost::range_category<boost_irange> iterator_category; // iterator category

value_type testVtype = *(new_range.begin()); //

assert(testVtype==8);

boost_irange w_newOne=new_range.advance_begin(1); // new range

printRange(w_newOne);

}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *