S
SW
Hi, yesterday I came across a problem. I'd been sure that the snippet
below is valid and evaluates to true:
std::string::const_iterator() == std::string::const_iterator()
(or for any other standard iterator e.g.
std::vector<int>::const_iterator) and I was quite surprised that VC 2008
fails on assertion at this (can be disabled by defining _SECURE_SCL 0
and _HAS_ITERATOR_DEBUGGING 0). But, now I am no longer sure that this
code is 100% valid. With asserts disabled it works as expected
(evaluates to true) and so in g++ 4.2.3 on Linux.
I can't imagine this wasn't valid because it simply doesn't make sense.
For me it is as good as:
typedef int * IntPtr;
IntPtr() == IntPtr()
So, should I change my code or just disable assertions and forget about it?
Thanks,
Szymon
below is valid and evaluates to true:
std::string::const_iterator() == std::string::const_iterator()
(or for any other standard iterator e.g.
std::vector<int>::const_iterator) and I was quite surprised that VC 2008
fails on assertion at this (can be disabled by defining _SECURE_SCL 0
and _HAS_ITERATOR_DEBUGGING 0). But, now I am no longer sure that this
code is 100% valid. With asserts disabled it works as expected
(evaluates to true) and so in g++ 4.2.3 on Linux.
I can't imagine this wasn't valid because it simply doesn't make sense.
For me it is as good as:
typedef int * IntPtr;
IntPtr() == IntPtr()
So, should I change my code or just disable assertions and forget about it?
Thanks,
Szymon