
2 May
2005
2 May
'05
9:20 p.m.
Eric Niebler schrieb:
I think it's not worth it here. besides that it isn't a performance overhead on most containers you don't expect that from a keyword.
Huh, *I* would expect that from a keyword.
can you explain that? why do expect a keyword to create temporaries and use outdated values? (and what are the semantics in other languages which have that keyword?)
std::string str="ab"; foreach(char c,str){ if(str.length() == 2) str+='c'; std::cerr << c << std::endl; }
See the discussion about iterator invalidation. This code has undefined behavior.
you're right (even the SGI stl documentation admits that the std::string invalidation rules are strange). -- Stefan Strasser