[libcxx-commits] [libcxx] 7e69bd9 - [libc++] Use __enable_if_t and is_integral in cstddef
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun May 29 03:05:06 PDT 2022
Author: Nikolas Klauser
Date: 2022-05-29T12:05:02+02:00
New Revision: 7e69bd9bf00ece8ac63aab91f73673d0d731bc24
URL: https://github.com/llvm/llvm-project/commit/7e69bd9bf00ece8ac63aab91f73673d0d731bc24
DIFF: https://github.com/llvm/llvm-project/commit/7e69bd9bf00ece8ac63aab91f73673d0d731bc24.diff
LOG: [libc++] Use __enable_if_t and is_integral in cstddef
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D126469
Added:
Modified:
libcxx/include/__type_traits/enable_if.h
libcxx/include/cstddef
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/enable_if.h b/libcxx/include/__type_traits/enable_if.h
index d7ccd6fd0368..c5e8df45ea58 100644
--- a/libcxx/include/__type_traits/enable_if.h
+++ b/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
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index 2b0659ab8ee7..8daba076d7db 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -35,6 +35,8 @@ Types:
#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 @@ namespace std // purposefully not versioned
{
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 @@ constexpr byte operator~ (byte __b) noexcept
~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
More information about the libcxx-commits
mailing list