44
While playing with this answer by user GMan I crafted the following snippet (compiled with Visual C++ 9):
class Class {
public:
operator void() {}
};
Class object;
static_cast<void>( object );
(void)object;
object.operator void();
after stepping over with the debugger I found out that casting to void doesn't invoke Class::operator void(), only the third invokation (with explicitly invoking the operator) actually invokes the operator, the two casts just do nothing.
Why is the operator void not invoked with the cast syntax?