So, if I try this example and in g++ compile with -D_GLIBCXX_DEBUG :
std::vector<int> v1, v2 ; std::distance( v1.begin(), v2.end() ) ;
I see these errors on startup:
error: attempt to compute the different between two iterators from different sequences.
There is more output, but I think this should cover it. This previous thread covers the same for Visual Studio .
source share