title: Why do scoped enums allow use of | operator when initializing using previously assigned values?
body: <p>I'm converting unscoped enumerations to scoped enumerations, and have run across a puzzle.</p>
  
  <p>Stroustrup, <em>C++ Programming Language</em>, 4th edition, Section 8.4.1, documents that scoped enum classes are not implicitly converted to integral types, and provides code for operators <code>|</code> and <code>&amp;</code> as an example of how to use <code>static_cast</code> to work around that.</p>
  
  <p>Shouldn't the following initialization using the <code>|</code> operator on previously defined <code>enum</code> values be illegal?</p>
  
  <pre><code>enum class FileCopy {
      PreviousHDUs   = 1,
      CurrentHDU     = 2,
      FollowingHDUs  = 4,
      AllHDUs        = PreviousHDUs | CurrentHDU | FollowingHDUs,
      CurrentHeader  = 8
  };
  
  int main()
  {
      std::cout &lt;&lt; static_cast&lt;int&gt;( FileCopy::AllHDUs) &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>I've tested this on Wandbox using both clang &amp; gcc HEAD with <code>--pedantic-errors</code>, and it compiles and returns the expected output, <code>7</code>.  That's not to say it's legal, just that it seems to be accepted by the compilers. </p>
  
  <p>Is this explicitly documented behavior?  I've been unable to parse the <a href="https://en.cppreference.com/w/cpp/language/enum" rel="nofollow noreferrer">documentation</a> in a way that describes this behavior.</p>