title: Using default in a switch statement when switching over an enum
body: <p>What is your procedure when switching over an enum where every enumeration is covered by a case?  Ideally you'd like the code to be future proof, how do you do that?</p>
  
  <p>Also, what if some idiot casts an arbitrary int to the enum type?  Should this possibility even be considered? Or should we assume that such an egregious error would be caught in code review?</p>
  
  <pre><code>enum Enum
  {
      Enum_One,
      Enum_Two
  };
  
  Special make_special( Enum e )
  {
      switch( e )
      {
          case Enum_One:
              return Special( /*stuff one*/ );
  
          case Enum_Two:
              return Special( /*stuff two*/ );
      }
  }
  
  void do_enum( Enum e )
  {
      switch( e )
      {
          case Enum_One:
              do_one();
              break;
  
          case Enum_Two:
              do_two();
              break;
      }
  }
  </code></pre>
  
  <ul>
  <li>leave off the default case, gcc will warn you (will visual studio?)</li>
  <li>add a default case with a <code>assert(false)</code>;</li>
  <li>add a default case that throws a catchable exception</li>
  <li>add a default case that throws a non-catchable exception (it may just be policy to never catch it or always rethrow).</li>
  <li>something better I haven't considered</li>
  </ul>
  
  <p>I'm especially interested in why you choose to do it they way you do.</p>