trying to piecewise construct a map(in a map of maps) with initializer list, getting syntax error:
std::unordered_map<int, std::unordered_map<int, int>> map;
map.emplace(std::piecewise_construct,
std::forward_as_tuple(1),
std::forward_as_tuple(std::initializer_list<std::pair<int, int>>{{1,1}}));
try out here: https://onlinegdb.com/S1tzFQkDv
The key type in initializer_list
needs to be const
:
std::unordered_map<int, std::unordered_map<int, int>> map;
map.emplace(std::piecewise_construct,
std::forward_as_tuple(1),
std::forward_as_tuple(std::initializer_list<std::pair<const int, int>>{{1,1}}));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.