Is it possible to have a class object return a true/false value, so I can do something like this:
MyClass a;
...
if (a)
do_something();
I can accomplish (almost) what I want by overloading the ! operator:
class MyClass {
...
bool operator!() const { return !some_condition; };
...
}
main()
MyClass a;
...
if (!a)
do_something_different();
but I haven't found a way to overload what would be the "empty" operator. Of course, using the == operator to check for true/false is also possible, and is in fact what I have been doing so far.