24.5. operator boolean const *() const
Since all integral types are out of the question, and void* is too generic, maybe a non-void pointer type would work, as in:
class ExpressibleThing
{
private:
struct boolean { private: void operator delete(void*); };
public:
operator boolean const *() const;
};
The reason that a struct is used is to allow it to be a private nested type. This can then be given a hidden operator delete() in order to preclude instances of ExpressibleThing being passed to delete. It also prevents the declaration of variables of the operator's return type, boolean const*, and conversion to another pointer type will require two static_cast operator applications.
|