15
When I try to use std::distance with a custom iterator under gcc 4.7, it complains about not finding the difference_type. I have sadly no idea why it fails.
#include <iterator>
class nit {
public:
typedef int difference_type;
};
int main() {
const nit test1;
std::distance( test1, test1 );
return 0;
}
gives the error:
/usr/include/c++/4.7/bits/stl_iterator_base_funcs.h:114:5: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<nit>’