#ifndef CGAL_ITERATOR_FROM_INDICES_H #define CGAL_ITERATOR_FROM_INDICES_H #include namespace CGAL { template struct Default_coordinate_access { typedef Ref_ result_type; template Ref_ operator()(T const& t, int i)const{ return t[i]; } }; //TODO: default type for Value_: typename same_cv::type::value_type>::type template ()[0]) #else Value_& #endif , class Coord_access = Default_coordinate_access > class Iterator_from_indices : public boost::iterator_facade, Value_, std::bidirectional_iterator_tag, Ref_> { friend class boost::iterator_core_access; //FIXME: use int to save space //FIXME: use a signed type typedef std::size_t index_t; Container_* cont; index_t index; Coord_access ca; void increment(){ ++index; } void decrement(){ --index; } void advance(std::ptrdiff_t n){ index+=n; } ptrdiff_t distance_to(Iterator_from_indices const& other)const{ return static_cast(other.index) -static_cast(index); } bool equal(Iterator_from_indices const& other)const{ return index==other.index; } Ref_ dereference()const{ //FIXME: use the functor properly //Uh, and what did I mean by that? return ca(*cont,index); } public: Iterator_from_indices(Container_& cont_,std::size_t n) : cont(&cont_), index(n) {} template Iterator_from_indices(Container_& cont_,std::size_t n,T const&t) : cont(&cont_), index(n), ca(t) {} }; } #endif // CGAL_ITERATOR_FROM_INDICES_H