fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <type_traits>
  4. using namespace std;
  5.  
  6. enum struct XXX : int {
  7. AAA = 123,
  8. BBB = 456,
  9. };
  10.  
  11. int main() {
  12. cout << "Is XXX self-assignable: "
  13. << boolalpha << is_assignable<XXX, XXX>::value
  14. << endl;
  15.  
  16. auto x = XXX::AAA;
  17. x = XXX::BBB;
  18. cout << "... but x == "
  19. << static_cast<underlying_type_t<XXX>>(x)
  20. << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Is XXX self-assignable: false
... but x == 456