Open junxnone opened 2 years ago
std::string
std::map
#include <map> #include <string> enum StringValue { evNotDefined, evStringValue1, evStringValue2, evStringValue3, evEnd }; std::map<std::string, StringValue> s_mapStringValues; s_mapStringValues["x"] = evStringValue1; s_mapStringValues["y"] = evStringValue2; s_mapStringValues["z"] = evStringValue3; switch(s_mapStringValues[InputString]) { case evStringValue1: cout << "Detected the first valid string." << endl; break; case evStringValue2: cout << "Detected the second valid string." << endl; break; ... ...
Reference
Brief
std::string
作为 case 选项std::map
置换std::map