fork(1) download
  1. #include <iostream>
  2. enum OperationMode
  3. {
  4. FIRST = 0x1,
  5. SECOND = 0x2
  6. };
  7.  
  8. OperationMode operator | (OperationMode lhs, OperationMode rhs )
  9. {
  10. std::cout << "OperationMode operator |\n";
  11. // Cast to int first otherwise we'll just end up recursing
  12. return static_cast< OperationMode >( static_cast< int >( lhs ) | static_cast< int >( rhs ) );
  13. }
  14.  
  15. OperationMode operator + (OperationMode lhs, OperationMode rhs )
  16. {
  17. std::cout << "OperationMode operator +\n";
  18. // Cast to int first otherwise we'll just end up recursing
  19. return static_cast< OperationMode >( static_cast< int >( lhs ) | static_cast< int >( rhs ) );
  20. }
  21.  
  22. int main ()
  23. {
  24. OperationMode a = FIRST + SECOND;
  25. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
OperationMode operator +