fork(2) download
  1. #include <iostream>
  2.  
  3. enum class NumericType
  4. {
  5. None = 0,
  6. PadWithZero = 0x01,
  7. NegativeSign = 0x02,
  8. PositiveSign = 0x04,
  9. SpacePrefix = 0x08
  10. };
  11.  
  12. NumericType operator |= (NumericType &a, NumericType b) {
  13. unsigned ai = static_cast<unsigned>(a);
  14. unsigned bi = static_cast<unsigned>(b);
  15. ai |= bi;
  16. return a = static_cast<NumericType>(ai);
  17. }
  18.  
  19. std::ostream & operator << (std::ostream &os, NumericType x) {
  20. return os << static_cast<unsigned>(x);
  21. }
  22.  
  23. int main ()
  24. {
  25. NumericType a = NumericType::PadWithZero;
  26. NumericType b = NumericType::SpacePrefix;
  27. a |= b;
  28. std::cout
  29. << std::hex
  30. << "a: " << a << std::endl
  31. << "b: " << b << std::endl;
  32. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
a: 9
b: 8