|
Boost : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-08-22 12:36:19
"Alex Chovanec" <achovane_at_[hidden]> wrote in message
news:cgajri$ils$1_at_sea.gmane.org...
> Is there a utility in Boost which determines at compile time whether
or not
> a given type meets the most basic requirements for an iterator,
without
> generating an error if the test fails?
Currently there is detail::is_incrementable, which works well if you
only need to distinguish between iterators and very different types.
For instance, I would guess that very few if any containers are
incrementable (I'd be happy to be proved wrong here), so that if you
want define a function which behaves differently for container and
iterators you can use is_incrementable.
> The 'is_iterator' struct template is a model of the "integral
constant
> expression" concept. Thus, 'is_iterator<T>::value' evaluates to true
> if-and-only-if type T defines iterator traits as well as overloaded
> operators with the following signatures:
>
> boost::iterator_reference<T>::type operator*(void) const;
> boost::iterator_pointer<T>::type operator->(void) const;
> T & operator++(void);
> T operator++(int);
Don't forget pointers. Also these operators can also be defined as
non-member functions.
Jonathan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk