title: How to efficiently identify string commands?
body: <p>Given a series of commands and very unique code that must be run for each:</p>
  <pre><code>if(cmd == &quot;cmd.setBoosterRocket&quot;)
      ...
  else if(cmd == &quot;cmd.windSales&quot;)
      ...
  else if(cmd == &quot;cmd.selfDustruct&quot;)
      ...
  else if(cmd == &quot;cmd.unleashHounds&quot;)
      ...
  </code></pre>
  <p>How might this be optimized?  Be put into a switch statement, that is?</p>
  <p>I considered making a vector of hashes:</p>
  <pre><code>std::hash&lt;std::string&gt; hasher;
  for(std::string command : m_commandList)
      m_mashes.push_back(hasher(command)
  </code></pre>
  <p>But a vector cannot be accessed as part of a switch case statement as it is not a constexpr.  The list of string commands is known at compile time, and I could potentially hardcode the hash values...but that does not seem like a great idea.</p>