|
Boost Users : |
Subject: [Boost-users] iterator_facade and distance()
From: Andrej van der Zee (andrejvanderzee_at_[hidden])
Date: 2011-04-15 20:55:31
Hi,
I am trying to implement an iterator using boost::iterator_facade. It
works fine but it is very slow, I think because the distance()
function takes lineair time as it is seems to be implemented in terms
of increment(). I would like to implement the distance() function
myself but I am not sure how. I tried to implement distance_to() like
this:
class const_data_stream_iterator :
public boost::iterator_facade<const_data_stream_iterator,
char const,
boost::forward_traversal_tag>
{
public:
typedef boost::iterator_facade<const_data_stream_iterator, char
const, boost::forward_traversal_tag> facade_t;
private:
friend class boost::iterator_core_access;
facade_t::difference_type
difference_to(const_data_stream_iterator & to) const
{
...
}
};
But this does not work. How can I do this?
Thank you,
Andrej
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