fork download
  1. #include <iostream>
  2.  
  3. class X {
  4. public:
  5. explicit operator bool() const {
  6. return true;
  7. }
  8. };
  9.  
  10. int main() {
  11. X x;
  12.  
  13. if (x) {
  14. std::cout << x + 100;
  15. }
  16.  
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:22: error: no match for ‘operator+’ in ‘x + 100’
prog.cpp:14:22: note: candidate is:
prog.cpp:14:22: note: operator+(int, int) <built-in>
prog.cpp:14:22: note:   no known conversion for argument 1 from ‘X’ to ‘int’
stdout
Standard output is empty