Why does this code compile? Since no operator[]
is declared, I'd expect it to fail. Where is the operator[]
definition coming from?
struct Test {
operator bool() const {
return true;
}
};
int main(int argc, char** argv) {
Test test;
if (test["wut"])
cout << "Success (test[\"wut\"])\n";
}