c++.beta - Boolean conversions
- Christof Meerwald (31/31) Jun 08 2003 struct A
struct A { typedef void (A::*member)() const; operator member() const { return &A::f; } void f() const; }; int main() { A a; bool b = a; // Error: need explicit cast to convert // from: A // to : bool if (a) // Error: undefined use of struct or union { return 0; } return 1; } Extracted from Boost's scoped_ptr. I guess the compiler should use the user-defined conversion function and then a standard conversion from pointer to member to bool (see 4.12 Boolean conversions [conv.bool]). bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jun 08 2003