I would like to combine the two std::unordered_map : mapA and mapB , while maintaining priority for the elements from mapA if both maps contain the same key.
Is there an elegant way to do this (and not check every key .. my cards contain a large number of elements)?
Example:
mapA = {{"sugar",0.1},{"salt",0.2}} mapB = {{"sugar",0.3},{"pepper",0.4}}
As a result, I would like to:
result = {{"sugar",0.1},{"salt",0.2},{"pepper",0.4}}
Ignoring the key value {"sugar",0.3} from mapB
Thanks.
source share