Title
unordered_multimap::insert hint iterator
Status
c++17
Section
[unord.req]
Submitter
Isaac Hier

Created on 2015-09-16.00:00:00 last changed 47 months ago

Messages

Date: 2016-08-05.03:33:05

Proposed resolution:

Change the insert-with-hint row in Table 102 Unordered associative container requirements like so:

a.insert(qp, t);
iterator
Requires: If t is a non-const
...
Average Case
...
Date: 2016-08-05.03:33:05

[ 2016-08 - Chicago ]

Thurs AM: Moved to Tentatively Ready

Date: 2015-09-16.00:00:00

I have been wondering about the C++ standard requirements regarding the hint iterator for insertion into an unordered_multimap (and I imagine a similar question could be asked of unordered_map, but I have not researched that topic). As far as I can tell, it seems perfectly valid for an implementation to allow only valid dereferencable iterators to be used as the hint argument for this member function. If that is correct, it means that one could not expect the end iterator to be used as a valid hint nor could one use the begin iterator of an empty unordered_multimap as the hint. However, this essentially precludes all uses of inserter on an empty unordered_multimap seeing as the inserter functor requires that a hint iterator be passed to its constructor.

Howard Hinnant:

The intent of the standard is that the iterator produced from container c by c.end() is a valid (but non-dereferenceable) iterator into container c. It is reachable by every other iterator into c.

It appears to me that you and the Bloomberg implementation have fallen victim to a type-o in the Unordered associative container requirements, Table 102. The row containing:

a.insert(q, t);

should read instead:

a.insert(p, t);

The distinction is that p is valid, and q is both valid and dereferenceable. The correction of this type-o would make unordered container insert consistent with unordered emplace_hint, associative insert, and associative emplace_hint.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-05 03:33:05adminsetmessages: + msg8412
2016-08-05 03:33:05adminsetstatus: new -> ready
2015-10-20 03:02:06adminsetmessages: + msg7572
2015-09-16 00:00:00admincreate