#include <iostream> using namespace std; struct test { explicit operator bool() const { return true; } }; int main() { test a; float b = static_cast<float>(a); return 0; }
Standard input is empty
prog.cpp: In function ‘int main()’:
prog.cpp:11:35: error: invalid static_cast from type ‘test’ to type ‘float’
float b = static_cast<float>(a);
^
prog.cpp:11:11: warning: unused variable ‘b’ [-Wunused-variable]
float b = static_cast<float>(a);
^
Standard output is empty