
Hi, I have encountered a problem with vc8.0 std library. I was able to fix it, but I'm not sure what is correct according to standard. The problem can be narrowed to one simple case. In vc8.0 method iterator std::list<>::erase(iterator First, iterator Last) returns a 'singular' iterator when the list is empty after erase operation. Because I'm dependant on the returned iterator to make insertion at this point later on, I had to make an explicit workaroud. I would expect it to return .end() iterator in this case. Is this behavior correct according to standard or not? If not, is it reasonable to submit bug report? Thanks, Pavol

Pavol Droba ha escrito:
Hi,
I have encountered a problem with vc8.0 std library. I was able to fix it, but I'm not sure what is correct according to standard.
The problem can be narrowed to one simple case. In vc8.0 method
iterator std::list<>::erase(iterator First, iterator Last)
returns a 'singular' iterator when the list is empty after erase operation. Because I'm dependant on the returned iterator to make insertion at this point later on, I had to make an explicit workaroud.
I would expect it to return .end() iterator in this case.
Is this behavior correct according to standard or not? If not, is it reasonable to submit bug report?
The std says in lib.sequence.reqmts (23.1.1.8): "The iterator returned by a.erase(q1,q2) points to the element pointed to by q2 prior to any elements being erased. If no such element exists, a.end() is returned." So, it seems to me like a bug in VC8.0 stdlib. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

On Tue, Aug 31, 2004 at 11:45:50AM +0200, Joaqu?n M? L?pez Mu?oz wrote:
Pavol Droba ha escrito:
Hi,
I have encountered a problem with vc8.0 std library. I was able to fix it, but I'm not sure what is correct according to standard.
The problem can be narrowed to one simple case. In vc8.0 method
iterator std::list<>::erase(iterator First, iterator Last)
returns a 'singular' iterator when the list is empty after erase operation. Because I'm dependant on the returned iterator to make insertion at this point later on, I had to make an explicit workaroud.
I would expect it to return .end() iterator in this case.
Is this behavior correct according to standard or not? If not, is it reasonable to submit bug report?
The std says in lib.sequence.reqmts (23.1.1.8):
"The iterator returned by a.erase(q1,q2) points to the element pointed to by q2 prior to any elements being erased. If no such element exists, a.end() is returned."
So, it seems to me like a bug in VC8.0 stdlib.
Thanks for explanation. I have submitted a bug report to microsoft. Regards, Pavol

I would expect it to return .end() iterator in this case.
Is this behavior correct according to standard or not? If not, is it reasonable to submit bug report?
Yes, the std says: "The iterator returned by a.erase(q1,q2) points to the element pointed to by q2 prior to any elements being erased. If no such element exists, a.end() is returned." So your expectations were valid, and the implementation appears to have a bug. John.
participants (3)
-
Joaquín Mª López Muñoz
-
John Maddock
-
Pavol Droba