Boost logo

Boost :

Subject: Re: [boost] clang type traits
From: Doug Gregor (doug.gregor_at_[hidden])
Date: 2011-06-10 13:13:46

On Tue, Jun 7, 2011 at 3:41 PM, Daniel James <dnljms_at_[hidden]> wrote:
> On 28 May 2011 23:47, Bryce Lelbach <blelbach_at_[hidden]> wrote:
>> John, Clang has supported GCC style type trait intrinsics (__is_pod, etc) for
>> awhile. The <boost/type_traits/intrinsics.hpp> header doesn't detect this. May
>> I fix this?
> I just noticed this change. To avoid warnings, you should check that a
> macro is defined before using it. Common macros can be added to
> detail/workaround.hpp to make that easier.
> Although in this case I think we should be using clang's feature
> checking macros. For example (untested):
>    #if defined(__has_extension)
>    #   if __has_extension(is_union)
>    #       define BOOST_IS_UNION(T) __is_union(T)
>    #   endif
>    // ....
>    #endif
> Maybe it should also check for clang first. That's pretty verbose
> though, perhaps something to consider for a future release. But it
> should be more robust than checking version numbers.

For Clang feature tests, please use __has_feature (or the newer
__has_extension) rather than peeking at Clang version numbers.
__has_feature/__has_extension are language-dialect aware and represent
what the compiler actually supports, while Clang version numbers can
vary widely from one vendor to another (e.g., Apple's version numbers
for its Clang-based compilers are distinct from the LLVM project's
version numbers for Clang).

  - Doug

Boost list run by bdawes at, gregod at, cpdaniel at, john at