title: How to automatically convert strongly typed enum into int?
body: <pre><code>#include &lt;iostream&gt;
  
  struct a {
    enum LOCAL_A { A1, A2 };
  };
  enum class b { B1, B2 };
  
  int foo(int input) { return input; }
  
  int main(void) {
    std::cout &lt;&lt; foo(a::A1) &lt;&lt; std::endl;
    std::cout &lt;&lt; foo(static_cast&lt;int&gt;(b::B2)) &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>The <code>a::LOCAL_A</code> is what the strongly typed enum is trying to achieve, but there is a small difference : normal enums can be converted into integer type, while strongly typed enums can not do it without a cast.</p>
  
  <p>So, is there a way to convert a strongly typed enum value into an integer type without a cast? If yes, how?</p>