static unordered_map<string,RoadType> const road_type_string_map = {
{ "unclassified", RoadType::unclassified },
{ "service", RoadType::service },
{ "residential", RoadType::residential },
{ "tertiary", RoadType::tertiary },
{ "secondary", RoadType::secondary },
{ "primary", RoadType:primary }
};
上述代码在 Ubuntu 上编译20.04,但在22.04我收到错误:
sim.h:276:1: error: could not convert ‘{{"unclassified", unclassified}, {"service", service}, {"residential", residential}, {"tertiary", tertiary}, {"secondary", secondary}, {"primary", primary}}’ from ‘<brace-enclosed initializer list>’ to ‘const std::unordered_map<std::__cxx11::basic_string<char>, RoadType>’
276 | };
makefile 使用“g++ -std=c++17 -Wall -g”