Consider introducing a map
function combining contains check and value retrieval
#1608
Labels
map
function combining contains check and value retrieval
#1608
If one wants to check whether a
map
contains a value and retrieve it one currently is nudged into a double iteration pattern, e.g.,We currently provide
map::get
which bundles this into one operation (though it also generates code which does a double iteration), but this can only be used for this use case if the there is some magic "default" value which cannot appear in the genuine value domain (else we couldn't distinguish entries at default from absent values).We should consider introducing a
map
method (e.g.,get_if
or similar) which given a key returns anoptional
value (set if present, else unset). We could then also use this to provide a more efficient implementation ofget
.The text was updated successfully, but these errors were encountered: