This project is read-only.

C++ question: What is the need for ' operator type_safe_bool_type () '

Apr 1, 2013 at 7:21 AM
I commented out :
typedef bool (opt::*type_safe_bool_type) () const;
        CPPLINQ_INLINEMETHOD operator type_safe_bool_type () const throw ()
            return is_initialized ? &opt::has_value : nullptr;
And the test sample I wrote compiles.
Apr 1, 2013 at 11:36 AM
Check out for an explanation of how it works
Jun 26, 2013 at 8:56 PM
Hi there.

First of let me apologize for the long delay before answering your question.

The purpose of the operator is to be able to safely write:
if (obj) 
    // Do something
The pattern was inspired by the boost code where I first saw this technique.

Perhaps the safebool approach is a better approach. If you do a pull-request I can take a look at the code.