Created on 2022-04-19.00:00:00 last changed 6 months ago
This wording is relative to N4910.
Modify [associative.reqmts.general] as indicated:
-5- For set and multiset the value type is the same as the key type. For map and multimap it is equal to pair<const Key, T>.
Modify [unord.req.general] as indicated:
-7- For unordered_set and unordered_multiset the value type is the same as the key type. For unordered_map and unordered_multimap it is pair<const Key, T>.
[ 2022-05-17; Reflector poll ]
Set priority to 3 after reflector poll. One vote for NAD.
Keys for elements of associative containers are presented as const subobjects, preventing their modification by user code according to [dcl.type.cv] p4.However, that does not prevent those keys to be transparently replaced, for example via
std::map<int, int> map; map.emplace(1, 2); using KT = std::map<int, int>::key_type; auto it = map.begin(); it->first.~KT(); new (const_cast<int*>(&it->first)) KT(3);
This, of course, breaks the ordering of the keys, and should be undefined behavior.Related issue: CWG 2514.
|2022-05-17 11:58:16||admin||set||messages: + msg12464|
|2022-04-24 08:08:25||admin||set||messages: + msg12423|