fork download
  1. #include <iostream>
  2.  
  3. using std::cout;
  4.  
  5. struct Test {
  6. operator bool() const {
  7. return true;
  8. }
  9. };
  10.  
  11. int main(int argc, char** argv) {
  12. Test test;
  13.  
  14. if (test["wut"])
  15. cout << "Success (test[\"wut\"])\n";
  16.  
  17. if (test["a"])
  18. cout << "unreachable\n";
  19.  
  20. if (test[""])
  21. cout << "UB\n";
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Success (test["wut"])