C++11 introduced the constexpr
keyword for defining a constant expression.
A constant expression is a variable or function that may be evaluated at compile time. This has many uses, including extending a switch statement to support full strings.
C++ only supports using an integer as the condition in a switch
statement and an integer that is known at compile time in a case
statement.
You can define a hash function and use it to convert a string to an integer to use in a switch
statement.
If you define that hash function as a constexpr
you can use it to convert a string literal to an integer to use in a case
statement as well.