How to check that the passed Iterator is a random access iterator?
If Iterator is a random access iterator, then std::iterator_traits<Iterator>::iterator_category will be std::random_access_iterator_tag. The cleanest way to implement this is probably to create a second function template and have Foo call it: template <typename Iterator> void FooImpl(Iterator first, Iterator last, std::random_access_iterator_tag) { // … } template <typename Iterator> void Foo(Iterator first, Iterator last) { typedef typename … Read more