Boost logo

Boost :

From: Bohdan (warever_at_[hidden])
Date: 2002-09-25 05:10:46


"David B. Held" <dheld_at_[hidden]> wrote in message
news:amqs87$jd0$1_at_main.gmane.org...
> "Bohdan" <warever_at_[hidden]> wrote in message
> news:amqo40$888$1_at_main.gmane.org...
> > Does standart allow such iterators ?
>
> But, of course. Pointers into arrays can be passed as iterators to
standard
> algorithms. That was part of the motivation for the iterator design...to
> mimic builtin pointer types. My STL implementation (RW) already has a
> specialization for T* (I assume it's standard).

I was unclear, sorry. I meant smart pointers lacking ++, -- operators.

> struct trivial_iterator_tag { };
>
> template <class T>
> struct iterator_traits< boost::shared_ptr<T> >
> {
> typedef T value_type;
> typedef std::ptrdiff_t difference_type;
> typedef T* pointer;
> typedef T& reference;
> typedef trivial_iterator_tag iterator_category;
> };

difference_type for trivial_iterator ... maybe just void ?:

 struct trivial_iterator_tag { };

 template <class T>
 struct iterator_traits< boost::shared_ptr<T> >
 {
    typedef T value_type;
    typedef void difference_type;
    typedef T* pointer;
    typedef T& reference;
    typedef trivial_iterator_tag iterator_category;
 };


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk