[libcxx-commits] [PATCH] D126469: [libc++] Use __enable_if_t and is_integral in cstddef

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 28 06:23:23 PDT 2022


philnik updated this revision to Diff 432718.
philnik added a comment.

- Try to fix CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126469/new/

https://reviews.llvm.org/D126469

Files:
  libcxx/include/__type_traits/enable_if.h
  libcxx/include/cstddef


Index: libcxx/include/cstddef
===================================================================
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -35,6 +35,8 @@
 
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_integral.h>
 #include <stddef.h>
 #include <version>
@@ -60,11 +62,6 @@
 {
 enum class byte : unsigned char {};
 
-
-template <bool> struct __enable_if_integral_imp {};
-template <> struct __enable_if_integral_imp<true> { using type = byte; };
-template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type;
-
 constexpr byte  operator| (byte  __lhs, byte __rhs) noexcept
 {
     return static_cast<byte>(
@@ -105,6 +102,10 @@
         ~static_cast<unsigned int>(__b)
     ));
 }
+
+template <class _Tp>
+using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
+
 template <class _Integer>
   constexpr _EnableByteOverload<_Integer> &
   operator<<=(byte& __lhs, _Integer __shift) noexcept
Index: libcxx/include/__type_traits/enable_if.h
===================================================================
--- libcxx/include/__type_traits/enable_if.h
+++ libcxx/include/__type_traits/enable_if.h
@@ -10,7 +10,6 @@
 #define _LIBCPP___TYPE_TRAITS_ENABLE_IF_H
 
 #include <__config>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126469.432718.patch
Type: text/x-patch
Size: 1543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220528/b8a34ea1/attachment.bin>


More information about the libcxx-commits mailing list