Код: Выделить всё
struct T {
explicit operator bool() const { return true; }
};
Код: Выделить всё
T t;
Код: Выделить всё
bool b = t.operator bool();
bool b = static_cast(t);
bool b = bool{t}; // or bool(t)
bool b(t); // converting initialiser
bool b{static_cast(t)};
Код: Выделить всё
if (t)
/* statement */;
Подробнее здесь: https://stackoverflow.com/questions/399 ... out-a-cast
Мобильная версия