Boost logo

Boost Users :

Subject: Re: [Boost-users] iterator_facade and distance()
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-04-16 00:12:53


At Sat, 16 Apr 2011 09:55:31 +0900,
Andrej van der Zee wrote:
>
> 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?

You misspelled "distance_to." Fix the spelling and it should work better.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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