[cfe-dev] Keyword warnings in libc++'s type_traits and other headers
Marshall Clow
mclow.lists at gmail.com
Mon Dec 23 16:29:36 PST 2013
On Dec 23, 2013, at 1:16 PM, Howard Hinnant <howard.hinnant at gmail.com> wrote:
>
> Two further questions:
>
> 1. Do these keywords come with __has_feature tests (like __is_class does)? If not, they should.
>
> 2. If they do come with __has_feature tests, how about libc++ doing the same thing it does for is_class et al.?
>
> #if !__has_feature(is_void)
>
> template <class _Tp> struct __is_void : public false_type {};
> template <> struct __is_void<void> : public true_type {};
>
> #endif // !__has_feature(is_void)
>
> template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
> : public __is_void<typename remove_cv<_Tp>::type> {};
>
> That way we don't need major surgery. We avoid the conflict if it exists. And we take advantage of the compiler intrinsic if it exists.
This sounds good to me, but I think it’ll be a bit more involved than that:
#if !__has_feature(is_void)
template <class _Tp> struct __is_void : public false_type {};
template <> struct __is_void<void> : public true_type {};
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
: public __is_void<typename remove_cv<_Tp>::type> {};
#else
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
: public integral_constant<bool, __is_void(typename remove_cv<_Tp>::type)>;
#endif // !__has_feature(is_void)
— Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131223/4abd762f/attachment.html>
More information about the cfe-dev
mailing list