I define an user-defined conversion operator to bool
and use it in a conditional:
struct T {
explicit operator bool() { return true; }
};
int main() {
T t;
return t ? 0 : 1;
}
To my surprise this compiles (on gcc) despite the explicit
. Is this allowed by the C++11 standard? I searched the standard but couldn't find it.
Aucun commentaire:
Enregistrer un commentaire