Is it possible to make an operator member_function_pointer_type()
without using typedefs (i.e. by specifying the type of the member function pointer inline)?
For example, when implementing the Safe Bool Idiom:
class Foo
{
typedef void (Foo::*bool_type)() const;
public:
operator bool_type() const;
};
is it possible to write out the type of bool_type
directly when declaring the operator? If so, how?
It seems that this is the only case where one cannot declare a (typecasting)
operator
without using atypedef
.Had it been another function name or another
operator x
, then it works fine:Demo.