Is there a simple way in C++ to convert a string to an enum (similar to Enum.Parse in C#)? A switch statement would be very long, so I was wondering i
Enum.Parse
saw this example somewhere
#include #include enum responseHeaders { CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING, }; // String switch paridgam struct responseHeaderMap : public std::map { responseHeaderMap() { this->operator[]("content-encoding") = CONTENT_ENCODING; this->operator[]("content-length") = CONTENT_LENGTH; this->operator[]("transfer-encoding") = TRANSFER_ENCODING; }; ~responseHeaderMap(){} };