fork download
  1. #include <iostream>
  2.  
  3. struct MyType
  4. {
  5. operator size_t(){return 0;}
  6. MyType &operator[](size_t){return*this;}
  7. };
  8.  
  9. int main()
  10. {
  11. int a[] = {1, 2}, b = 0;
  12. MyType mt;
  13. std::cout << mt[a] << std::endl;
  14. //std::cout << b[mt] << std::endl;
  15. std::cout << mt[mt] << std::endl;
  16. }
  17.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
1
0