member cast operators
From Cppwiki
A special form of member function exists for providing conversion to particular types.
As an example, the following code allows objects of type foo to be used in boolean contexts, such as the expression and if statement checks:
class foo {
void dont_use();
public:
typedef void (Foo::* pfnFooMember)();
operator pfnFooMember() {
return bValid ? dont_use : 0;
}
private:
bool bValid;
};
Note that for this example, pointer-to-member was choosen over operator bool() because bool has far more implicit conversions than does a pointer-to-member.
An in-depth discussion can be found here: http://www.artima.com/cppsource/safebool.html