It exists and works well:
std::map <int, std::string> x { std::make_pair (42, "foo"), std::make_pair (3, "bar") };
Remember that the map value type is pair <const key_type, mapped_type> , so you basically need a list of pairs with the same or convertible types.
Unified initialization with std :: pair makes code even easier
std::map <int, std::string> x { { 42, "foo" }, { 3, "bar" } };
doublep Jul 14 '10 at 20:55 2010-07-14 20:55
source share