M
Matthias Kaeppler
Hello,
I was wondering, does dereferencing past-the-end
iterators yield undefined behavior? Especially, is
the result of calling an STL algorithm on an empty
range undefined?
For example (pseudocode):
begin = find(...);
end = find(...);
sort(begin, find, pred);
If begin is a past-the-end iterator, is the call
to sort() an unsafe operation? Is it good practice
to check iterators for being valid before passing
them to an STL algo?
Regards,
Matthias
I was wondering, does dereferencing past-the-end
iterators yield undefined behavior? Especially, is
the result of calling an STL algorithm on an empty
range undefined?
For example (pseudocode):
begin = find(...);
end = find(...);
sort(begin, find, pred);
If begin is a past-the-end iterator, is the call
to sort() an unsafe operation? Is it good practice
to check iterators for being valid before passing
them to an STL algo?
Regards,
Matthias