
Daniel James skrev:
On 09/12/2007, Thorsten Ottosen <thorsten.ottosen@dezide.com> wrote:
Well, the table at
http://igaztanaga.drivehq.com/unordered/unordered/comparison.html
says that erase() does not throw for ordered containers (which is correct). Anyway, this means any argument used to assume that predicate evaluation is a no-throw should be the same for unordered containers.
comp.std.c++ would be the place to discuss logical inconsistencies in the standard.
Right, but we are allowed to investigate potential problems if we see them :-)
Why does erase( const_iterator ) (and range version), not provide the no-throw guarantee?
Because that's what the standard says... Perhaps I'm being pedantic in my reading, the intent might have been that the hash function is never called during those overloads of erase.
This implementation actually does provide the no throw guarantee. But Jeremy Maitin-Shepard's version (on which it is based) didn't because the iterators didn't store the bucket, and required the hash to be calculated to work out which bucket the elements to be deleted are in. Which I think the standard allows.
Ok, I think you right the standard allows that. But this is also a bit irritating, because I cannot portable take advantage of your stronger guarantee. feThis again begs the question of how much the stronger guarantee affects performance?
Does erase give the strong guarantee otherwise?
Exceptions are only allowed from the hash or predicate objects. So no throw if they are no throw.
yes, but my question was: *if an exception is thrown*, then what? I assume you give the basic guarantee? -Thorsten