Boost logo

Boost :

From: Alex Chovanec (achovane_at_[hidden])
Date: 2004-08-22 13:09:53

"Jonathan Turkanis" <technews_at_[hidden]> wrote in message

> 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.

In this case, I need to know whether or not type T is dereferenceable (and
more generally, whether or not it's an iterator). I have a small template
metaprogram which determines how an instance of type T should be treated. If
it's an iterator, I want to dereference it. Otherwise, I don't.

> Don't forget pointers. Also these operators can also be defined as
> non-member functions.

Pointers are fairly easy to handle. I forgot to mention that I provide a
partial template specialization for this case: for any type T,
'is_iterator<T *>::value' evaluates to true.

You bring up an important point about operators defined as non-member
functions. My current implementation doesn't handle this case, but I may yet
be able to fix that. :-)

Thanks for the feedback,


Boost list run by bdawes at, gregod at, cpdaniel at, john at