title: static_cast on integer to enum conversion
body: <p>There is some function that takes in an enum as argument</p>
  
  <pre><code>void myfunc(myEnum input);
  </code></pre>
  
  <p>As I understand, if I have to give an integer to this function, it is advised to explicitly cast it to enum, the reason being all integers may not be valid enum values.</p>
  
  <p>As per <strong><a href="http://msdn.microsoft.com/en-us/library/c36yw7x9%28v=vs.120%29.aspx" rel="nofollow">MSDN</a></strong> </p>
  
  <blockquote>
    <p>"The static_cast operator can explicitly convert an integral value to
    an enumeration type. If the value of the integral type does not fall
    within the range of enumeration values, the resulting enumeration
    value is undefined."</p>
  </blockquote>
  
  <p>and as per the C++ standards <strong>5.2.9 Static cast -> 10</strong></p>
  
  <blockquote>
    <p>"A value of integral or enumeration type can be explicitly converted
    to an enumeration type. The value is unchanged if the original value
    is within the range of the enumeration values (7.2). Otherwise, the
    resulting value is unspecified (and might not be in that range)."</p>
  </blockquote>
  
  <p>So what's the point using <code>static_cast</code> in this scenario? Is there some option that would raise exceptions on values outside the enum range (other than writing explicit code for that)?</p>