Код: Выделить всё
#include
#include
char Find(const std::map& map, int key) {
auto iter = map.find(key);
if (iter == map.end())
return 'X';
return iter->second;
}
char Find2(const std::map& map, int key) {
return map.find(key)->second;
}
int main()
{
// part 1
std::map x{{0,'0'}, {4,'4'}};
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/76003457/set-a-sentinel-value-for-stdmap-end-for-gcc-compiler[/url]
Мобильная версия