#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using std::map;
using std::string;
using std::cout;
using std::endl;
void printMap(const map<string, double>& mp)
{
for (auto element : mp) {
cout << element.first << ": " << element.second << endl;
}
cout << endl;
}
int main()
{
map<string, double> mp{ { "c++", 3.14 }, { "c", 5.18 } };
for_each(mp.begin(), mp.end(), [](map<std::string, double>::value_type& element) {
element.second *= 2;
});
printMap(mp);
return 0;
}
/*
run:
c: 10.36
c++: 6.28
*/