Boost logo

Boost :

Subject: Re: [boost] [type_traits] Interest in is_iterator type trait?
From: Peter Dimov (lists_at_[hidden])
Date: 2014-08-20 08:33:22


Mathias Gaunard wrote:

> AFAIK an iterator T doesn't have to provide an iterator_category typedef,
> only std::iterator_traits<T> does.

That's true. However, pre-C++14, iterator_traits<It>::iterator_category
causes a hard error (not SFINAE) when It is not an iterator. In C++14, the
default iterator_traits<It> is empty when It doesn't have the nested types.
So

is_iterator<It, tag> :- is_convertible<X::iterator_category, tag> where X is
iterator_traits<It> in C++14, It otherwise

is the best we can do.


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