
I am facing problem related to iterator_range. It's type is not propagating properly, when I return such thing from a function. (compiler VS 7.1 ,Windows ) The code below shows it. This is an extension of a vector, which returns range. typedef std::pair<std::size_t,std::size_t> pair_t; typedef std::vector<std::size_t> index_t; template<typename T> class vector_e : private std::vector<T>{ public: typedef vector_e<T> self_type; typedef typename std::vector<T>::iterator iterator; typedef typename std::vector<T>::const_iterator const_iterator; typedef typename std::vector<T>::pointer pointer; typedef typename std::vector<T>::const_pointer const_pointer; typedef typename std::vector<T>::reference reference; typedef typename std::vector<T>::const_reference const_reference; typedef typename std::vector<T>::difference_type difference_type; typedef typename std::vector<T>::size_type size_type; //typedef sub_range_t<self_type> range; //typedef sub_range_t<const self_type> const_range; typedef typename std::vector<T>::size_type size_type; typedef typename boost::permutation_iterator<typename iterator,typename index_t::const_iterator> index_iterator; typedef typename boost::permutation_iterator<typename const_iterator,typename index_t::const_iterator> const_index_iterator; //typedef sub_range_t<self_type,index_iterator,const_index_iterator> index_range; //typedef sub_range_t<self_type,const_index_iterator,const_index_iterator> const_index_range; typedef boost::iterator_range<index_iterator> index_range; typedef boost::iterator_range<const_index_iterator> const_index_range; typedef boost::sub_range<self_type> range; typedef boost::sub_range<const self_type> const_range; vector_e() : std::vector<T>(){} using std::vector<T>::begin; using std::vector<T>::end; using std::vector<T>::operator []; using std::vector<T>::insert; const_iterator const_begin()const{ return begin(); } const_iterator const_end()const{ return end(); } index_iterator begin_i(const index_t& i){ return boost::make_permutation_iterator(begin(),i.begin()); } const_index_iterator begin_i(const index_t& i)const{ return boost::make_permutation_iterator(begin(),i.begin()); } index_iterator end_i(const index_t& i){ return boost::make_permutation_iterator(begin(),i.end()); } const_index_iterator end_i(const index_t& i)const{ return boost::make_permutation_iterator(begin(),i.end()); } range get_range(const pair_t& r){ return boost::make_iterator_range(begin()+r.first,begin()+r.second); } const_range get_range(const pair_t& r)const{ return boost::make_iterator_range(begin()+r.first,begin()+r.second); } index_range get_range(const index_t& i){ index_iterator b = boost::make_permutation_iterator(begin(),i.begin()); index_iterator e = boost::make_permutation_iterator(begin(),i.end()); return boost::make_iterator_range(b,e); } const_index_range get_range(const index_t& i)const{ const_index_iterator b = boost::make_permutation_iterator(begin(),i.begin()); const_index_iterator e = boost::make_permutation_iterator(begin(),i.end()); return boost::make_iterator_range(b,e); } }; Now, to use it like this, typedef vector_e<trace> trace_buffer; typedef boost::permutation_iterator<trace_buffer::iterator,index_t::iterator> index_iterator; typedef boost::sub_range<trace_buffer> trace_range; typedef boost::iterator_range<index_iterator> trace_index_range; trace_buffer traces; struct character{ index_t index; trace_index_range get_traces(){ index_iterator b = boost::make_permutation_iterator(traces.begin(),index.begin()); index_iterator e = boost::make_permutation_iterator(traces.begin(),index.end()); //return boost::make_iterator_range(b,e); return traces.get_range(index);///This doesn't work, while previous commented line works ! } }; Thus to say, I am unable to forward a call to iterator_range from one function to another preserving the type. (Previously the same problem was there with sub_range with 1.33.1 download. Now that one is solved with a later cvs version ) . Any help is appreciated .... thanks' abir -- Abir Basak, Member IEEE Software Engineer, Read Ink Technologies B. Tech, IIT Kharagpur email: abir@abirbasak.com homepage: www.abirbasak.com