Home:ALL Converter>Can i change the value of std map without finding it first

Can i change the value of std map without finding it first

Ask Time:2020-03-31T12:04:17         Author:Summit

Json Formatter

This is how currently i am changing the value of std::map

std::map<std::string, int> stdmapMasks;
stdmapMasks.insert(std::make_pair("VALUE", 1));
std::map<std::string, int>::iterator it = stdmapMasks.find('VALUE'); 
if (it != stdmapMasks.end())
    it->second = 42;

Can i change the value directly without the need to find the map element ?

Author:Summit,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60943283/can-i-change-the-value-of-std-map-without-finding-it-first
yy