Title
unordered_meow::merge() has incorrect Throws: clause
Status
c++20
Section
[unord.req]
Submitter
Tim Song

Created on 2017-06-14.00:00:00 last changed 46 months ago

Messages

Date: 2017-07-12.01:30:31

Proposed resolution:

This wording is relative to N4659.

  1. In [unord.req], edit Table 91 "Unordered associative container requirements" as indicated:

    Table 91 — Unordered associative container requirements (in addition to container)
    Expression Return type Assertion/note
    pre-/post-condition
    Complexity
    a.merge(a2) void Requires: a.get_allocator() == a2.get_allocator().
    Attempts to extract each element in a2 and insert it into a using the hash function and key equality predicate of a. In containers with unique keys, if there is an element in a with key equivalent to the key of an element from a2, then that element is not extracted from a2.
    Postconditions: Pointers and references to the transferred elements of a2 refer to those same elements but as members of a. Iterators referring to the transferred elements and all iterators referring to a will be invalidated, but iterators to elements remaining in a2 will remain valid.
    Throws: Nothing unless the hash function or key equality predicate throws.
    Average case 𝒪(N), where N is a2.size().
    Worst case 𝒪(N*a.size()+N).
Date: 2017-07-12.01:30:31

[ 2017-07 Toronto Monday issue prioritization ]

Priority 0; move to Ready

Date: 2017-06-14.00:00:00

As pointed out in this StackOverflow question, unordered_{map,multimap,set,multiset}::merge() may need to rehash to maintain its max_load_factor invariant, which may require allocation, which may throw.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2017-11-13 19:01:36adminsetstatus: voting -> wp
2017-10-17 18:34:55adminsetstatus: ready -> voting
2017-07-12 01:30:31adminsetmessages: + msg9343
2017-07-12 01:30:31adminsetstatus: new -> ready
2017-06-14 17:40:49adminsetmessages: + msg9258
2017-06-14 00:00:00admincreate