So I've got a few ptr_container instances floating around, and have
just tracked down a bug caused by (my) naff code essentially akin to
the following:
ptr_vector<int> vi;
ptr_vector<string> vs;
bool eq = (vi.begin() == vs.begin());
After digging I discovered the operator in question in void_ptr_iterator.hpp:
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator==( const void_ptr_iterator& l,
const void_ptr_iterator& r )
What is the reason for implementing comparison between different
iterator types? I have a few guesses but unsure of whether they're
sensible ones or not!
Of course disallowing comparison between differing pointer types won't
save people from comparing iterators from different containers, but I
think it's a little too easy to fall into this trap, and difficult to
spot the error once written in. (The equality comparison was an
unlikely case, and fortunately found it during thorough unit testing
:-) )
Is there any sensible way to suppress this behaviour, or are there any
comments on why I might be being a muppet?
Cheers,
Rob
--
Rob Desbois
Eml: rob.desbois@gmail.com