[iterator_facade] problem with dereference method

I'm attempting to write a simple iterator, but am having problems with it. The following code snippet shows the datum that is used to feed the iterator, the beginning of the iterator class, the method that is producing a compiler error, and the error. typedef std::vector<DataEdge> Edges; struct NeighboringEdgeInfo { NeighboringEdgeInfo() : size(0),current_pos(0) {} NeighboringEdgeInfo(size_t size_,size_t current_pos_) : size(size_),current_pos(current_pos_) {} Edges::const_iterator start; size_t size; size_t current_pos; }; class AdjacentEdgeIter : public boost::iterator_facade<AdjacentEdgeIter,DataEdge,boost::forward_traversal_tag> { .... inline const DataEdge& AdjacentEdgeIter::dereference() const { return *(node.start+node.current_pos); <<< produces the error } The error: iterator_facade.hpp:517: error: invalid initialization of reference of type 'boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned int>&' from expression of type 'const boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned int>' Note that I have tried to make the NeighboringEdgeInfo::start iterator mutable to avoid this error, but it didn't help. Can somebody explain what is going on??

Fixed my compiler error by making the second template parameter of iterator_facade "DataEdge const".
participants (1)
-
Jeffrey Holle