I am trying to write a program that hashes a string to use it in a switch and when I call the hash function I get the error : expression must have a constant value
The code in question is:
unsigned int hashString(const std::string string_input, int hash_seed)
{
{
return !string_input[0]
? 33129 : (hashString(string_input, 1)
* 54) ^ string_input[0];
}
}
bool evaluateString(std::string str)
{
string first_word;
stringstream inputStream { str };
commandStream >> first_word;
switch (hashString(first_word, 0))
{
case hashString(ipo::Io::STRING_HELLO, 0):
/* code */
break;
default:
break;
}
}
The error occurs here: case hashString(ipo::Io::STRING_HELLO, 0):
It marks the ipo as a problem
How could I fix it
Thank you for your help
Aucun commentaire:
Enregistrer un commentaire