I am using a std::map to map some unsigned char machine values into human readable string types, e.g.:
std::map<unsigned char, std::string> DEVICE_TYPES = {
{ 0x00, "Validator" },
{ 0x03, "SMART Hopper" },
{ 0x06, "SMART Payout" },
{ 0x07, "NV11" },
};
I'd like to modify this so that if the key passed is not present, the map will return "Unknown". I want the caller interface to stay the same (i.e. they just retrieve their string from the map using the [] operator). What's the best way to do this? I have C++11 on Windows 7 available.
[]operator.