#include #include #include #include #include #include #include using namespace boost::lambda; using namespace boost::multi_index; using boost::multi_index_container; template void modify_range( Index& i,typename Index::iterator first,typename Index::iterator last, Modifier mod) { while(first!=last)i.modify(first++,mod); } template void modify_unstable_range( Index& i,typename Index::iterator first,typename Index::iterator last, Modifier mod) { typedef std::vector buffer_type; buffer_type v; while(first!=last)v.push_back(first++); for(typename buffer_type::iterator it=v.begin(),it_end=v.end(); it!=it_end;i.modify(*it++,mod)); } template void dump(const Container& c) { std::copy( c.begin(),c.end(), std::ostream_iterator(std::cout," ")); std::cout< > > > multi_index_type; multi_index_type m; for(int i=0;i<10;++i)m.insert(i); modify_range(m,m.begin(),m.end(),adder(-2)); dump(m); modify_range(m,m.begin(),m.end(),boost::lambda::_1-=2); dump(m); modify_unstable_range(m,m.begin(),m.end(),adder(2)); dump(m); modify_unstable_range(m,m.begin(),m.end(),boost::lambda::_1+=2); dump(m); }