Home > Archive > VC STL > February 2005 > Bug in MSVC 7.1 hash_set::erase documentation?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Bug in MSVC 7.1 hash_set::erase documentation?
|
|
| Joaquín M López Muñoz 2005-02-14, 9:11 pm |
| The documentation on hash_set::erase implementation for
MSVC .NET (http://tinyurl.com/6qo6r) states that
"The member functions never throw an exception."
Yet, looking at the code of the internal _Hash class,
the memfun erase calls _Hashval(), which in turns
invokes the user-provided hashing function. So, it seems
to me that hash_set::erase can actually throw (if the
hash function throws.) Am I missing something?
--
Joaqu=EDn M L=F3pez Mu=F1oz
Telef=F3nica, Investigaci=F3n y Desarrollo
| |
| Tom Widmer 2005-02-14, 9:11 pm |
| Joaquín M López Muñoz wrote:
> The documentation on hash_set::erase implementation for
> MSVC .NET (http://tinyurl.com/6qo6r) states that
>
> "The member functions never throw an exception."
>
> Yet, looking at the code of the internal _Hash class,
> the memfun erase calls _Hashval(), which in turns
> invokes the user-provided hashing function. So, it seems
> to me that hash_set::erase can actually throw (if the
> hash function throws.) Am I missing something?
I'm not sure that the user provided hashing function is allowed to throw:
"For all values _Key of type Key, the call hash_comp(_Key) serves as a
hash function, which yields a distribution of values of type size_t. The
function supplied by hash_compare returns _Key."
If it throws, it isn't meeting the above requirement. Arguable of
course, and it's not worth worrying about such things until
unordered_set or similar is standardised.
I note that the proposal for unordered_set says:
"For hashed associative containers, no clear() function throws an
exception. No erase() function throws an exception unless that exception
is thrown by the container's Hash or Pred object (if any)."
Tom
|
|
|
|
|