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

Howard Hinnant via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 5 16:27:28 PDT 2018


That sounds right to me.

Howard

On Jun 5, 2018, at 4:07 PM, Erik Pilkington <erik.pilkington at gmail.com> wrote:
> 
> Looks like the initial purpose was to implement a poor man's explicit operator bool that returned a pointer to member, but it was removed in r151088.
> 
> 
> On 2018-06-05 3:57 PM, Eric Fiselier via cfe-dev wrote:
>> I'm not sure what the purpose is. I agree it doesn't seem to have any effect, and the git blame comes back to the initial commit for libc++.
>> Changing the layout of `__nat` now would be an ABI break; so that's out of the question. But I have some upcoming patches that are going
>> to remove most usages of it.
>> 
>> @Howard, do you recall what the purpose of this was? Something to do with initializing empty structs maybe?
>> 
>> /Eric
>> 
>> On Tue, Jun 5, 2018 at 2:11 AM, Li, Zeyang via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>> 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
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>> 
>> 
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> 
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180605/066d971f/attachment.sig>


More information about the cfe-dev mailing list