Boost logo

Boost Users :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2006-11-17 08:00:30


Sebastian Redl <sebastian.redl <at> getdesigned.at> writes:

>
> Markus Werle wrote:
> > Hi!
> >
> > This was detected by profiling. I expected the code below
> > to have a rather cheap std::distance call because my iterator
> > was tagged as random_access.
> >
> std::distance doesn't understand the new iterator categories,

Ouch! The tutorial is definitely too short!
So I can use std::random_access_iterator_tag instead?

I simply want an iterator that works with current STL as random
iterator. Class Demo uses a std::size_t as index type.
How do I build my iterator with iterator_facade?

Problem: If I use

template <typename ValueT, typename SizeT, typename IndexOperatorT>
class signal_iter
        : public boost::iterator_facade
        <signal_iter<ValueT, SizeT, IndexOperatorT>,
        ValueT,
        std::random_access_iterator_tag,
        ValueT>
{ [...] }

iterator_facade implementation applies unary minus to unsigned type
in its code:

      template <class Facade1, class Facade2>
      static typename Facade1::difference_type distance_from(
          Facade1 const& f1, Facade2 const& f2, mpl::true_)
      {
          return -f1.distance_to(f2);
      }

How can I circumvent this?

Markus


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