[cfe-dev] Usage of __for_bool_ value in __nat {} classes

Li, Zeyang via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 5 01:11:37 PDT 2018


I was looking through clang's c++ standard library, and found this class in
the shared_ptr class.

class shared_ptr
...
private:
        struct __nat {int __for_bool_;};
...
};

and I understand that this class is used to detect whether type conversion
is possible at compile time, but its member __for_bool_ is never used
anywhere in the class or the weak_ptr counterpart. So my question is, what
is the point of __for_bool_, why not simply use an empty class for the same
purpose?

I'm sure the standard library authors definitely knows better than me.
Please help.

Thanks,
Zeyang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180605/75b3c82e/attachment.html>


More information about the cfe-dev mailing list