Getting std::iterator_category from boost iterator adaptor

I have a situation where I want to specialize a class template on the
basis of iterator_category, but I don't see how to get one of the
standard categories when passed a boost iterator adapter. Currently,
std::iterator_traits<MyIter>::iterator_category is giving me:
boost::iterator_tag

Raoul Gough
Does your standard library really have a *specialization*? Most
libraries use tag dispatching to discriminate categories - it works
nicely with the inheritance structure of existing categories.
Technically, you are right - a standard library is allowed to use
specialization. AFAIK, none of them do, and we hope that when (if)
our proposal is accepted, tag convertibility will be an acceptable
standards-compliant mechanism. So, while I suggest you avoid
specialization and use tag dispatching instead, if you must do it:
// True iff T is a tag "derived" from Tag
template

David Abrahams
Aha - I had even tested std::distance, but couldn't figure out how it knew that the boost category matched random_access_iterator_tag. For some reason, I didn't realise that it was using function overloading rather than specialization. Of course, a specialization wouldn't make any sense in this case. On the other hand, I actually do need a specialization for the python range class extensions (which is where the original problem arose)...
[snip hairy MPL code]
OK, I've written something slightly simpler using is_convertible,
since I really only need to cover two cases - a forward iterator or
better (I'm using is_convertible
participants (2)
-
David Abrahams
-
Raoul Gough