Boost logo

Boost Users :

From: Jeffrey Holle (jeffreyholle_at_[hidden])
Date: 2007-09-22 22:50:26


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??


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net