std::map<std::string, ...> не обязан создавать временный std::string при каждом поискеЕсли ключ уже приходит как
std::string_view, можно использовать transparent comparator:
std::map<std::string, int, std::less<>> status_codes{
{"not_found", 404},
{"timeout", 504}
};
std::string_view key = "timeout";
auto match = status_codes.find(key);
