[cfe-dev] __has_feature coverage
Marshall Clow
mclow.lists at gmail.com
Thu May 1 07:48:37 PDT 2014
Recently, reading llvm/tools/clang/docs/LanguageExtensions.rst, I saw a list of type_trait primitives
supported by clang.
One of them caught my eye: __is_nothrow_constructible — that could be handy for use in libc++.
So I ran a quick test:
__is_nothrow_constructible(int)
and it returned true.
Then I tried:
__has_feature(is_nothrow_constructible)
and it returned false.
Well, that’s not useful to me; I need to be able to tell when I can use that feature.
So I whipped up a program to test all of the type_traits listed in that file (attached),
and to see if I can check (using __has_feature) whether or not they are implemented.
Turns out that __has_feature returns false for the following type traits:
__has_feature(is_interface_class) = 0
__has_feature(is_destructible) = 0
__has_feature(is_nothrow_destructible) = 0
__has_feature(is_nothrow_assignable) = 0
__has_feature(is_nothrow_constructible) = 0
__is_interface_class is a MS extension; so that’s fine.
__is_destructible and __is_nothrow_destructible are described as “partially implemented”, and attempts to use them fail.
On the other hand:
__is_nothrow_constructible(int) returns 1
__is_nothrow_assignable(int&, int) returns 1
So these two seem to work (for at least one case)
It seems to me that we should have feature tests for these type traits if we expect people to use them
So, I’d like to see
__has_feature(is_nothrow_constructible)
and __has_feature(is_nothrow_assignable)
return 1
— Marshall
-------------- next part --------------
A non-text attachment was scrubbed...
Name: features.cpp
Type: application/octet-stream
Size: 4451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140501/d1115c5c/attachment.obj>
More information about the cfe-dev
mailing list