fork(2) download
  1. struct foo
  2. {
  3. operator int&()
  4. {
  5. return i;
  6. }
  7.  
  8. operator const int& () const
  9. {
  10. return i;
  11. }
  12.  
  13. private:
  14. int i;
  15. };
  16.  
  17. int main()
  18. {
  19. foo f;
  20. switch (f)
  21. {
  22.  
  23. }
  24. }
Compilation error #stdin compilation error #stdout 0s 3292KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:11: error: ambiguous default type conversion from ‘foo’
  switch (f)
           ^
prog.cpp:20:11: error:   candidate conversions include ‘foo::operator int&()’ and ‘foo::operator const int&() const’
stdout
Standard output is empty