
"Alex Chovanec" <achovane@engin.umich.edu> wrote in message news:cgajri$ils$1@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