Don't assume that std::vector<int>::const_iterator has a nested difference_type. Use iterator_traits.