Код: Выделить всё
#include
#include
int main() {
std::map m;
m[1] = 2;
m[2] = 4;
for (auto &[k, v] : m) {
v++; //
Подробнее здесь: [url]https://stackoverflow.com/questions/79847808/how-to-iterate-flat-map-in-range-based-for-loop-updating-values[/url]
Мобильная версия