Fix and extend key extraction for unique map/set containers by frederick-vs-ja · Pull Request #5050 · microsoft/STL (original) (raw)
Currently, the key-extracting optimization mechanism incorrectly catches some volatile
-qualified glvalues (due to _Remove_cvref_t
) and attempts to bind them to a const K&
reference, which makes the program ill-formed. This PR make the mechanism never catch volatile
glvalues, which makes volatile
accepted under some conditions as specified by the standard.
In piecewise construction, when the first tuple
argument is a 1-tuple
, it's sometimes possible to directly treat its only tuple element as the key. Also, since C++23, it should be possible to directly get the key from suitable tuple<K, V>
and array<K, 2>
without additional construction. This PR attempts to extend the optimization mechanism to catch these cases.
The mechanism should also be usable for flat_set
and flat_map
.
Note that subrange
is intentionally ignored because the corresponding get
function copies (or moves) the key, which doesn't seem desired.