title: How to branch/switch on multiple conditions?
body: <p>Is there a way to branch on multiple condition without writing code that looks like a mess? Syntaxic sugar in C++11 or C++14 would be appreciated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  enum state
  {
      STATE_1,
      STATE_2,
      STATE_3,
      STATE_4,
      STATE_5,
      STATE_6,
      STATE_7,
      STATE_8,
  };
  
  state f(int a, bool b, const std::string&amp; str)
  {
      // How not to:
      if (a &lt; 0)
      {
          if (b == false)
          {
              if (str != "morning")
              {
                  return STATE_1;
              }
              else
              {
                  return STATE_2;
              }
          }
          else
          {
              if (str != "morning")
              {
                  return STATE_3;
              }
              else
              {
                  return STATE_4;
              }
          }
      }
      else // a &gt;= 0
      {
          if (b == false)
          {
              if (str != "morning")
              {
                  return STATE_5;
              }
              else
              {
                  return STATE_6;
              }
          }
          else
          {
              if (str != "morning")
              {
                  return STATE_7;
              }
              else
              {
                  return STATE_8;
              }
          }
      }
  }
  
  int main()
  {
      std::cout &lt;&lt; "State: " &lt;&lt; f(1, true, "morning") &lt;&lt; std::endl;
  }
  </code></pre>