This is something I came across reviewing the headers of OSG, it’s called the “safe bool idiom” and arises when we try to overload the bool operator of a class to make it part of boolean expressions… Of course this is wrong, let me spoil you a correct version of what should look like a class using the safe bool idiom

  class Testable {
    bool ok_;
    typedef void (Testable::*bool_type)() const;
    void this_type_does_not_support_comparisons() const {}
    explicit Testable(bool b=true):ok_(b) {}

    operator bool_type() const {
      return ok_==true ? 
        &Testable::this_type_does_not_support_comparisons : 0;

Simple, eh? Let’s examine what’s going on here. First, we typedef bool_type to be a pointer to a const member function of Testable, taking zero arguments and returning void. This is our magic type that allows for testing in Boolean contexts, without taking part in overloading contexts. Next, we define a conversion function to bool_type, just as we did with bool and void* earlier. Finally, we return “true” using a pointer to a member function (this_type_does_not_support_comparisons), which fits the bool_type, and a null value for “false”. It’s now possible to safely test instances of Testable in Boolean contexts. The strange name does have a purpose; read on to find out what it is!

Yeah, simple! the way I like it. XD