[libcxx-commits] [libcxx] [libc++][modules] Modularize <cstddef> (PR #107254)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 4 10:11:15 PDT 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/107254

>From 6a2351d50f6ffe56690aa05a6f2cf1a5a740b9bc Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 3 Sep 2024 16:48:56 -0400
Subject: [PATCH] [libc++] Modularize <cstddef>

Many headers include <cstddef> just for size_t, and pulling in additional
content (e.g. the traits used for std::byte) is unnecessary. To solve
this problem, this patch splits up `<cstddef>` into subcomponents so
that headers can include only the parts that they actually require.

This has the added benefit of making the modules build a lot stricter
with respect to IWYU, and also providing a canonical location where
we define `std::size_t` and friends (which were previously defined in
multiple headers like <cstddef> and <ctime>).

After this patch, there's still many places in the codebase where we
include <cstddef> when <__cstddef/size_t.h> would be sufficient. This
patch focuses on removing <cstddef> includes from __type_traits to make
these headers non-circular with <cstddef>. Additional refactorings can
be tackled separately.
---
 libcxx/include/CMakeLists.txt                 |  5 ++
 libcxx/include/__algorithm/ranges_minmax.h    |  1 +
 libcxx/include/__atomic/atomic.h              |  2 +
 libcxx/include/__charconv/to_chars_integral.h |  1 +
 libcxx/include/__cstddef/byte.h               | 84 +++++++++++++++++++
 libcxx/include/__cstddef/max_align_t.h        | 27 ++++++
 libcxx/include/__cstddef/nullptr_t.h          | 25 ++++++
 libcxx/include/__cstddef/ptrdiff_t.h          | 25 ++++++
 libcxx/include/__cstddef/size_t.h             | 25 ++++++
 libcxx/include/__exception/nested_exception.h |  2 +
 libcxx/include/__fwd/array.h                  |  3 +-
 libcxx/include/__fwd/complex.h                |  2 +-
 libcxx/include/__fwd/pair.h                   |  2 +-
 libcxx/include/__fwd/span.h                   |  2 +-
 libcxx/include/__fwd/subrange.h               |  2 +-
 libcxx/include/__fwd/tuple.h                  |  2 +-
 libcxx/include/__iterator/concepts.h          |  1 +
 libcxx/include/__iterator/iterator_traits.h   |  2 +
 libcxx/include/__iterator/wrap_iter.h         |  1 +
 libcxx/include/__mdspan/layout_stride.h       |  1 +
 libcxx/include/__memory/pointer_traits.h      |  1 +
 libcxx/include/__memory/shared_ptr.h          |  2 +
 libcxx/include/__memory/unique_ptr.h          |  1 +
 libcxx/include/__memory/uses_allocator.h      |  1 +
 .../__random/mersenne_twister_engine.h        |  1 +
 libcxx/include/__random/seed_seq.h            |  2 +
 .../__random/subtract_with_carry_engine.h     |  1 +
 libcxx/include/__ranges/subrange.h            |  1 +
 .../include/__string/constexpr_c_functions.h  |  2 +
 libcxx/include/__tuple/tuple_size.h           |  2 +
 .../include/__type_traits/aligned_storage.h   |  2 +-
 libcxx/include/__type_traits/aligned_union.h  |  2 +-
 libcxx/include/__type_traits/alignment_of.h   |  2 +-
 libcxx/include/__type_traits/extent.h         |  2 +-
 libcxx/include/__type_traits/is_allocator.h   |  2 +-
 libcxx/include/__type_traits/is_array.h       |  2 +-
 .../include/__type_traits/is_bounded_array.h  |  2 +-
 .../__type_traits/is_nothrow_destructible.h   |  2 +-
 .../include/__type_traits/is_null_pointer.h   |  2 +-
 libcxx/include/__type_traits/is_swappable.h   |  2 +-
 libcxx/include/__type_traits/rank.h           |  2 +-
 .../__type_traits/remove_all_extents.h        |  2 +-
 libcxx/include/__type_traits/remove_extent.h  |  2 +-
 libcxx/include/__type_traits/type_list.h      |  2 +-
 libcxx/include/__utility/in_place.h           |  1 +
 libcxx/include/__utility/pair.h               |  1 +
 libcxx/include/__utility/swap.h               |  1 +
 libcxx/include/any                            |  1 +
 libcxx/include/cstddef                        | 83 ++----------------
 libcxx/include/cstdio                         |  2 +-
 libcxx/include/cstdlib                        |  2 +-
 libcxx/include/cstring                        |  2 +-
 libcxx/include/ctime                          |  2 +-
 libcxx/include/cuchar                         |  2 +-
 libcxx/include/cwchar                         |  2 +-
 .../include/experimental/__simd/reference.h   |  1 +
 libcxx/include/experimental/__simd/scalar.h   |  1 +
 libcxx/include/experimental/__simd/simd.h     |  1 +
 .../include/experimental/__simd/simd_mask.h   |  1 +
 libcxx/include/experimental/__simd/vec_ext.h  |  1 +
 libcxx/include/module.modulemap               | 31 +++++--
 libcxx/include/typeinfo                       |  1 +
 libcxx/include/unordered_map                  |  2 +
 libcxx/include/unordered_set                  |  2 +
 .../test/libcxx/transitive_includes/cxx03.csv |  2 -
 .../test/libcxx/transitive_includes/cxx11.csv |  2 -
 .../test/libcxx/transitive_includes/cxx14.csv |  2 -
 .../test/libcxx/transitive_includes/cxx17.csv |  2 -
 .../test/libcxx/transitive_includes/cxx20.csv |  2 -
 .../test/libcxx/transitive_includes/cxx23.csv |  2 -
 .../test/libcxx/transitive_includes/cxx26.csv |  2 -
 .../bit/bit.pow.two/bit_ceil.pass.cpp         |  1 +
 .../bit/bit.pow.two/bit_floor.pass.cpp        |  1 +
 .../bit/bit.pow.two/bit_width.pass.cpp        |  1 +
 .../bit/bit.pow.two/has_single_bit.pass.cpp   |  1 +
 .../bit/bitops.count/countl_one.pass.cpp      |  1 +
 .../bit/bitops.count/countl_zero.pass.cpp     |  1 +
 .../bit/bitops.count/countr_one.pass.cpp      |  1 +
 .../bit/bitops.count/countr_zero.pass.cpp     |  1 +
 .../bit/bitops.count/popcount.pass.cpp        |  1 +
 .../std/numerics/bit/bitops.rot/rotl.pass.cpp |  1 +
 .../std/numerics/bit/bitops.rot/rotr.pass.cpp |  1 +
 82 files changed, 299 insertions(+), 123 deletions(-)
 create mode 100644 libcxx/include/__cstddef/byte.h
 create mode 100644 libcxx/include/__cstddef/max_align_t.h
 create mode 100644 libcxx/include/__cstddef/nullptr_t.h
 create mode 100644 libcxx/include/__cstddef/ptrdiff_t.h
 create mode 100644 libcxx/include/__cstddef/size_t.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 32579272858a8e..1f8ff29e2e2cfb 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -324,6 +324,11 @@ set(files
   __coroutine/coroutine_traits.h
   __coroutine/noop_coroutine_handle.h
   __coroutine/trivial_awaitables.h
+  __cstddef/byte.h
+  __cstddef/max_align_t.h
+  __cstddef/nullptr_t.h
+  __cstddef/ptrdiff_t.h
+  __cstddef/size_t.h
   __debug_utils/randomize_range.h
   __debug_utils/sanitizers.h
   __debug_utils/strict_weak_ordering_check.h
diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h
index 1b43b1e19cdec9..5f2e5cb2a1eeab 100644
--- a/libcxx/include/__algorithm/ranges_minmax.h
+++ b/libcxx/include/__algorithm/ranges_minmax.h
@@ -24,6 +24,7 @@
 #include <__ranges/access.h>
 #include <__ranges/concepts.h>
 #include <__type_traits/desugars_to.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_reference.h>
 #include <__type_traits/is_trivially_copyable.h>
 #include <__type_traits/remove_cvref.h>
diff --git a/libcxx/include/__atomic/atomic.h b/libcxx/include/__atomic/atomic.h
index bcea21f5ce2e17..af6d12b5e4ce91 100644
--- a/libcxx/include/__atomic/atomic.h
+++ b/libcxx/include/__atomic/atomic.h
@@ -16,8 +16,10 @@
 #include <__config>
 #include <__functional/operations.h>
 #include <__memory/addressof.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_floating_point.h>
 #include <__type_traits/is_function.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/remove_const.h>
 #include <__type_traits/remove_pointer.h>
diff --git a/libcxx/include/__charconv/to_chars_integral.h b/libcxx/include/__charconv/to_chars_integral.h
index 0369f4dfb9bda6..ccb5856df17993 100644
--- a/libcxx/include/__charconv/to_chars_integral.h
+++ b/libcxx/include/__charconv/to_chars_integral.h
@@ -21,6 +21,7 @@
 #include <__system_error/errc.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/make_32_64_or_128_bit.h>
 #include <__type_traits/make_unsigned.h>
diff --git a/libcxx/include/__cstddef/byte.h b/libcxx/include/__cstddef/byte.h
new file mode 100644
index 00000000000000..b8cfe5e8d1c7ef
--- /dev/null
+++ b/libcxx/include/__cstddef/byte.h
@@ -0,0 +1,84 @@
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CSTDDEF_BYTE_H
+#define _LIBCPP___CSTDDEF_BYTE_H
+
+#include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_integral.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 17
+namespace std { // purposefully not versioned
+
+enum class byte : unsigned char {};
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
+  return static_cast<byte>(
+      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)));
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept {
+  return __lhs = __lhs | __rhs;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
+  return static_cast<byte>(
+      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)));
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept {
+  return __lhs = __lhs & __rhs;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
+  return static_cast<byte>(
+      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)));
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept {
+  return __lhs = __lhs ^ __rhs;
+}
+
+_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
+  return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b)));
+}
+
+template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept {
+  return __lhs = __lhs << __shift;
+}
+
+template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
+  return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift));
+}
+
+template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept {
+  return __lhs = __lhs >> __shift;
+}
+
+template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
+  return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift));
+}
+
+template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
+  return static_cast<_Integer>(__b);
+}
+
+} // namespace std
+#endif // _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___CSTDDEF_BYTE_H
diff --git a/libcxx/include/__cstddef/max_align_t.h b/libcxx/include/__cstddef/max_align_t.h
new file mode 100644
index 00000000000000..7c09c7e7f30172
--- /dev/null
+++ b/libcxx/include/__cstddef/max_align_t.h
@@ -0,0 +1,27 @@
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
+#define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
+
+#include <__config>
+#include <stddef.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+using ::max_align_t _LIBCPP_USING_IF_EXISTS;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
diff --git a/libcxx/include/__cstddef/nullptr_t.h b/libcxx/include/__cstddef/nullptr_t.h
new file mode 100644
index 00000000000000..de3f7d4ab5fa75
--- /dev/null
+++ b/libcxx/include/__cstddef/nullptr_t.h
@@ -0,0 +1,25 @@
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CSTDDEF_NULLPTR_T_H
+#define _LIBCPP___CSTDDEF_NULLPTR_T_H
+
+#include <__config>
+#include <stddef.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::nullptr_t;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CSTDDEF_NULLPTR_T_H
diff --git a/libcxx/include/__cstddef/ptrdiff_t.h b/libcxx/include/__cstddef/ptrdiff_t.h
new file mode 100644
index 00000000000000..f8b5cdaaff01c9
--- /dev/null
+++ b/libcxx/include/__cstddef/ptrdiff_t.h
@@ -0,0 +1,25 @@
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CSTDDEF_PTRDIFF_T_H
+#define _LIBCPP___CSTDDEF_PTRDIFF_T_H
+
+#include <__config>
+#include <stddef.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H
diff --git a/libcxx/include/__cstddef/size_t.h b/libcxx/include/__cstddef/size_t.h
new file mode 100644
index 00000000000000..91abbf01318953
--- /dev/null
+++ b/libcxx/include/__cstddef/size_t.h
@@ -0,0 +1,25 @@
+//===---------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CSTDDEF_SIZE_T_H
+#define _LIBCPP___CSTDDEF_SIZE_T_H
+
+#include <__config>
+#include <stddef.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___CSTDDEF_SIZE_T_H
diff --git a/libcxx/include/__exception/nested_exception.h b/libcxx/include/__exception/nested_exception.h
index feb489f87f62f5..4c7970d167ffa5 100644
--- a/libcxx/include/__exception/nested_exception.h
+++ b/libcxx/include/__exception/nested_exception.h
@@ -13,6 +13,8 @@
 #include <__exception/exception_ptr.h>
 #include <__memory/addressof.h>
 #include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_base_of.h>
 #include <__type_traits/is_class.h>
 #include <__type_traits/is_constructible.h>
diff --git a/libcxx/include/__fwd/array.h b/libcxx/include/__fwd/array.h
index b429d0c5a95427..d7ca6c738a7d0c 100644
--- a/libcxx/include/__fwd/array.h
+++ b/libcxx/include/__fwd/array.h
@@ -10,7 +10,8 @@
 #define _LIBCPP___FWD_ARRAY_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
+#include <__type_traits/integral_constant.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__fwd/complex.h b/libcxx/include/__fwd/complex.h
index 22c78c5cc3c77a..092d2e10b12b5b 100644
--- a/libcxx/include/__fwd/complex.h
+++ b/libcxx/include/__fwd/complex.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___FWD_COMPLEX_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__fwd/pair.h b/libcxx/include/__fwd/pair.h
index af32628fe1e0d0..b8ba2b7e923241 100644
--- a/libcxx/include/__fwd/pair.h
+++ b/libcxx/include/__fwd/pair.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___FWD_PAIR_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/tuple.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__fwd/span.h b/libcxx/include/__fwd/span.h
index 8dafa742c19df5..5d473ee51c6b74 100644
--- a/libcxx/include/__fwd/span.h
+++ b/libcxx/include/__fwd/span.h
@@ -11,7 +11,7 @@
 #define _LIBCPP___FWD_SPAN_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 #include <limits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__fwd/subrange.h b/libcxx/include/__fwd/subrange.h
index 60a41da23dd44e..5b3a07e55348a6 100644
--- a/libcxx/include/__fwd/subrange.h
+++ b/libcxx/include/__fwd/subrange.h
@@ -11,8 +11,8 @@
 
 #include <__concepts/copyable.h>
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__iterator/concepts.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__fwd/tuple.h b/libcxx/include/__fwd/tuple.h
index 902770c29555ed..2ed32bc0df4e14 100644
--- a/libcxx/include/__fwd/tuple.h
+++ b/libcxx/include/__fwd/tuple.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___FWD_TUPLE_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h
index be2890bee49284..93ea7efd495378 100644
--- a/libcxx/include/__iterator/concepts.h
+++ b/libcxx/include/__iterator/concepts.h
@@ -34,6 +34,7 @@
 #include <__memory/pointer_traits.h>
 #include <__type_traits/add_pointer.h>
 #include <__type_traits/common_reference.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_pointer.h>
 #include <__type_traits/is_primary_template.h>
 #include <__type_traits/is_reference.h>
diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h
index 11af9e301842cf..4d9ad480cc4a29 100644
--- a/libcxx/include/__iterator/iterator_traits.h
+++ b/libcxx/include/__iterator/iterator_traits.h
@@ -24,6 +24,8 @@
 #include <__type_traits/common_reference.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/disjunction.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_convertible.h>
 #include <__type_traits/is_object.h>
 #include <__type_traits/is_primary_template.h>
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index 34f8d5f1663b24..549d8ff2dbd7db 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -17,6 +17,7 @@
 #include <__memory/addressof.h>
 #include <__memory/pointer_traits.h>
 #include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_convertible.h>
 #include <cstddef>
 
diff --git a/libcxx/include/__mdspan/layout_stride.h b/libcxx/include/__mdspan/layout_stride.h
index 86148ac849eca5..c386ab81251cd0 100644
--- a/libcxx/include/__mdspan/layout_stride.h
+++ b/libcxx/include/__mdspan/layout_stride.h
@@ -23,6 +23,7 @@
 #include <__mdspan/extents.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_convertible.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_nothrow_constructible.h>
 #include <__utility/as_const.h>
 #include <__utility/integer_sequence.h>
diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 0914aceb318b74..8e08eb74413ee5 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -15,6 +15,7 @@
 #include <__type_traits/conditional.h>
 #include <__type_traits/conjunction.h>
 #include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_class.h>
 #include <__type_traits/is_function.h>
 #include <__type_traits/is_void.h>
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index d487e4fbe3a953..4dd8022822d223 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -34,6 +34,8 @@
 #include <__type_traits/conditional.h>
 #include <__type_traits/conjunction.h>
 #include <__type_traits/disjunction.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_array.h>
 #include <__type_traits/is_bounded_array.h>
 #include <__type_traits/is_constructible.h>
diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index 7f5e0ea243c956..392cf421378214 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -23,6 +23,7 @@
 #include <__type_traits/common_type.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/dependent_type.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_array.h>
 #include <__type_traits/is_assignable.h>
diff --git a/libcxx/include/__memory/uses_allocator.h b/libcxx/include/__memory/uses_allocator.h
index 84310c3fa56739..16504e8b2a9989 100644
--- a/libcxx/include/__memory/uses_allocator.h
+++ b/libcxx/include/__memory/uses_allocator.h
@@ -11,6 +11,7 @@
 #define _LIBCPP___MEMORY_USES_ALLOCATOR_H
 
 #include <__config>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_convertible.h>
 #include <cstddef>
 
diff --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h
index 65280d7c5505f7..1f50e608ce8d4e 100644
--- a/libcxx/include/__random/mersenne_twister_engine.h
+++ b/libcxx/include/__random/mersenne_twister_engine.h
@@ -13,6 +13,7 @@
 #include <__algorithm/min.h>
 #include <__config>
 #include <__random/is_seed_sequence.h>
+#include <__type_traits/enable_if.h>
 #include <cstddef>
 #include <cstdint>
 #include <iosfwd>
diff --git a/libcxx/include/__random/seed_seq.h b/libcxx/include/__random/seed_seq.h
index 5cf84aeb8a72b3..c1a320a75c88aa 100644
--- a/libcxx/include/__random/seed_seq.h
+++ b/libcxx/include/__random/seed_seq.h
@@ -14,6 +14,8 @@
 #include <__algorithm/max.h>
 #include <__config>
 #include <__iterator/iterator_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_unsigned.h>
 #include <cstdint>
 #include <initializer_list>
diff --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h
index ec25fed49f9498..926333cdda45ee 100644
--- a/libcxx/include/__random/subtract_with_carry_engine.h
+++ b/libcxx/include/__random/subtract_with_carry_engine.h
@@ -14,6 +14,7 @@
 #include <__config>
 #include <__random/is_seed_sequence.h>
 #include <__random/linear_congruential_engine.h>
+#include <__type_traits/enable_if.h>
 #include <cstddef>
 #include <cstdint>
 #include <iosfwd>
diff --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h
index aba584ef933542..144746babb325f 100644
--- a/libcxx/include/__ranges/subrange.h
+++ b/libcxx/include/__ranges/subrange.h
@@ -33,6 +33,7 @@
 #include <__tuple/tuple_size.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/decay.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_pointer.h>
 #include <__type_traits/is_reference.h>
 #include <__type_traits/make_unsigned.h>
diff --git a/libcxx/include/__string/constexpr_c_functions.h b/libcxx/include/__string/constexpr_c_functions.h
index 32fc06e121b362..9b8871e2e71a38 100644
--- a/libcxx/include/__string/constexpr_c_functions.h
+++ b/libcxx/include/__string/constexpr_c_functions.h
@@ -13,11 +13,13 @@
 #include <__memory/addressof.h>
 #include <__memory/construct_at.h>
 #include <__type_traits/datasizeof.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_always_bitcastable.h>
 #include <__type_traits/is_assignable.h>
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_equality_comparable.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_trivially_copyable.h>
 #include <__type_traits/is_trivially_lexicographically_comparable.h>
diff --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple/tuple_size.h
index 18a17fd4d58780..21c9811abeee7b 100644
--- a/libcxx/include/__tuple/tuple_size.h
+++ b/libcxx/include/__tuple/tuple_size.h
@@ -12,6 +12,8 @@
 #include <__config>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_types.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_volatile.h>
 #include <cstddef>
diff --git a/libcxx/include/__type_traits/aligned_storage.h b/libcxx/include/__type_traits/aligned_storage.h
index 46aae12832f867..49b4e971bbb675 100644
--- a/libcxx/include/__type_traits/aligned_storage.h
+++ b/libcxx/include/__type_traits/aligned_storage.h
@@ -10,11 +10,11 @@
 #define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/nat.h>
 #include <__type_traits/type_list.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/aligned_union.h b/libcxx/include/__type_traits/aligned_union.h
index 005ed9a096ea8e..de62a4b1c2a331 100644
--- a/libcxx/include/__type_traits/aligned_union.h
+++ b/libcxx/include/__type_traits/aligned_union.h
@@ -10,9 +10,9 @@
 #define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/aligned_storage.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/alignment_of.h b/libcxx/include/__type_traits/alignment_of.h
index f2d069bf2488f7..8871c8ce110d67 100644
--- a/libcxx/include/__type_traits/alignment_of.h
+++ b/libcxx/include/__type_traits/alignment_of.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/extent.h b/libcxx/include/__type_traits/extent.h
index bab03fe997eb6b..1c34a4db1c4b52 100644
--- a/libcxx/include/__type_traits/extent.h
+++ b/libcxx/include/__type_traits/extent.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_EXTENT_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_allocator.h b/libcxx/include/__type_traits/is_allocator.h
index 144ffac4d7ce5b..191eeb9a1f5226 100644
--- a/libcxx/include/__type_traits/is_allocator.h
+++ b/libcxx/include/__type_traits/is_allocator.h
@@ -10,10 +10,10 @@
 #define _LIBCPP___TYPE_IS_ALLOCATOR_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/void_t.h>
 #include <__utility/declval.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_array.h b/libcxx/include/__type_traits/is_array.h
index dc23de28d2c63b..f34204e19ed899 100644
--- a/libcxx/include/__type_traits/is_array.h
+++ b/libcxx/include/__type_traits/is_array.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_bounded_array.h b/libcxx/include/__type_traits/is_bounded_array.h
index 211403d638d08c..a78b52e7062b82 100644
--- a/libcxx/include/__type_traits/is_bounded_array.h
+++ b/libcxx/include/__type_traits/is_bounded_array.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h
index c2d5ca87232aa1..41271a38f37116 100644
--- a/libcxx/include/__type_traits/is_nothrow_destructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_destructible.h
@@ -10,10 +10,10 @@
 #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_destructible.h>
 #include <__utility/declval.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_null_pointer.h b/libcxx/include/__type_traits/is_null_pointer.h
index 9f5697e232684e..abc5d142562f1e 100644
--- a/libcxx/include/__type_traits/is_null_pointer.h
+++ b/libcxx/include/__type_traits/is_null_pointer.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
 
 #include <__config>
+#include <__cstddef/nullptr_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/is_swappable.h b/libcxx/include/__type_traits/is_swappable.h
index 0b817e65099339..f4d687094bbca1 100644
--- a/libcxx/include/__type_traits/is_swappable.h
+++ b/libcxx/include/__type_traits/is_swappable.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/add_lvalue_reference.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_assignable.h>
@@ -18,7 +19,6 @@
 #include <__type_traits/is_nothrow_constructible.h>
 #include <__type_traits/void_t.h>
 #include <__utility/declval.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h
index 7f6fad1c540245..aeeedec40dee56 100644
--- a/libcxx/include/__type_traits/rank.h
+++ b/libcxx/include/__type_traits/rank.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TYPE_TRAITS_RANK_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/remove_all_extents.h b/libcxx/include/__type_traits/remove_all_extents.h
index d5373b51f52215..db7dab4a6c1322 100644
--- a/libcxx/include/__type_traits/remove_all_extents.h
+++ b/libcxx/include/__type_traits/remove_all_extents.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/remove_extent.h b/libcxx/include/__type_traits/remove_extent.h
index fe37b5c7266c6b..aceeb47069660b 100644
--- a/libcxx/include/__type_traits/remove_extent.h
+++ b/libcxx/include/__type_traits/remove_extent.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__type_traits/type_list.h b/libcxx/include/__type_traits/type_list.h
index 02905707ee37a2..0d9ca989583772 100644
--- a/libcxx/include/__type_traits/type_list.h
+++ b/libcxx/include/__type_traits/type_list.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
 
 #include <__config>
-#include <cstddef>
+#include <__cstddef/size_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__utility/in_place.h b/libcxx/include/__utility/in_place.h
index fa7a2f4bfd4a95..459b271675261c 100644
--- a/libcxx/include/__utility/in_place.h
+++ b/libcxx/include/__utility/in_place.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___UTILITY_IN_PLACE_H
 
 #include <__config>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/remove_cvref.h>
 #include <cstddef>
 
diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 0afbebcdc9f2ae..78534a3f399f25 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -25,6 +25,7 @@
 #include <__type_traits/common_type.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_assignable.h>
 #include <__type_traits/is_constructible.h>
diff --git a/libcxx/include/__utility/swap.h b/libcxx/include/__utility/swap.h
index ab88b8e0a0b531..ecfbdec75a2aeb 100644
--- a/libcxx/include/__utility/swap.h
+++ b/libcxx/include/__utility/swap.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___UTILITY_SWAP_H
 
 #include <__config>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_assignable.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_nothrow_assignable.h>
diff --git a/libcxx/include/any b/libcxx/include/any
index 5def14dc87e6bf..7630e8a057d055 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -90,6 +90,7 @@ namespace std {
 #include <__type_traits/aligned_storage.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_constructible.h>
 #include <__type_traits/is_function.h>
 #include <__type_traits/is_nothrow_constructible.h>
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index 592f6261a6de3f..2b138d9690393f 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -34,9 +34,6 @@ Types:
 */
 
 #include <__config>
-#include <__type_traits/enable_if.h>
-#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_integral.h>
 #include <version>
 
 #include <stddef.h>
@@ -53,80 +50,10 @@ Types:
 #  pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::nullptr_t;
-using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
-
-#if !defined(_LIBCPP_CXX03_LANG)
-using ::max_align_t _LIBCPP_USING_IF_EXISTS;
-#endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#if _LIBCPP_STD_VER >= 17
-namespace std { // purposefully not versioned
-
-enum class byte : unsigned char {};
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
-  return static_cast<byte>(
-      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)));
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept {
-  return __lhs = __lhs | __rhs;
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
-  return static_cast<byte>(
-      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)));
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept {
-  return __lhs = __lhs & __rhs;
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
-  return static_cast<byte>(
-      static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)));
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept {
-  return __lhs = __lhs ^ __rhs;
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
-  return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b)));
-}
-
-template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept {
-  return __lhs = __lhs << __shift;
-}
-
-template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
-  return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift));
-}
-
-template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept {
-  return __lhs = __lhs >> __shift;
-}
-
-template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
-  return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift));
-}
-
-template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
-  return static_cast<_Integer>(__b);
-}
-
-} // namespace std
-#endif // _LIBCPP_STD_VER >= 17
+#include <__cstddef/byte.h>
+#include <__cstddef/max_align_t.h>
+#include <__cstddef/nullptr_t.h>
+#include <__cstddef/ptrdiff_t.h>
+#include <__cstddef/size_t.h>
 
 #endif // _LIBCPP_CSTDDEF
diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio
index 7f94371081f8b1..a461c24dcc0193 100644
--- a/libcxx/include/cstdio
+++ b/libcxx/include/cstdio
@@ -96,6 +96,7 @@ void perror(const char* s);
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 
 #include <stdio.h>
 
@@ -115,7 +116,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::FILE _LIBCPP_USING_IF_EXISTS;
 using ::fpos_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 
 using ::fclose _LIBCPP_USING_IF_EXISTS;
 using ::fflush _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index c817fd8f4accda..1ecdd3a6d0328c 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -82,6 +82,7 @@ void *aligned_alloc(size_t alignment, size_t size);                       // C11
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 
 #include <stdlib.h>
 
@@ -99,7 +100,6 @@ void *aligned_alloc(size_t alignment, size_t size);                       // C11
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 using ::div_t _LIBCPP_USING_IF_EXISTS;
 using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
 using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstring b/libcxx/include/cstring
index c2c92b02e73cc1..5bb6e3e10628f2 100644
--- a/libcxx/include/cstring
+++ b/libcxx/include/cstring
@@ -57,6 +57,7 @@ size_t strlen(const char* s);
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/is_constant_evaluated.h>
 
 #include <string.h>
@@ -75,7 +76,6 @@ size_t strlen(const char* s);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 using ::memcpy _LIBCPP_USING_IF_EXISTS;
 using ::memmove _LIBCPP_USING_IF_EXISTS;
 using ::strcpy _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index f47b49a43e23ef..d2d2470f2fa60b 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -46,6 +46,7 @@ int timespec_get( struct timespec *ts, int base); // C++17
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 
 // <time.h> is not provided by libc++
 #if __has_include(<time.h>)
@@ -62,7 +63,6 @@ int timespec_get( struct timespec *ts, int base); // C++17
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::clock_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 using ::time_t _LIBCPP_USING_IF_EXISTS;
 using ::tm _LIBCPP_USING_IF_EXISTS;
 #if _LIBCPP_STD_VER >= 17
diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar
index f0015be275367d..bfc26f03aaf782 100644
--- a/libcxx/include/cuchar
+++ b/libcxx/include/cuchar
@@ -37,6 +37,7 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 
 #include <uchar.h>
 
@@ -57,7 +58,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 #if !defined(_LIBCPP_CXX03_LANG)
 
 using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 
 #  if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
 using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index 08cfac58c846ac..f5a26664c1c3e4 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -103,6 +103,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 */
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/copy_cv.h>
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_equality_comparable.h>
@@ -127,7 +128,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
 using ::tm _LIBCPP_USING_IF_EXISTS;
 using ::wint_t _LIBCPP_USING_IF_EXISTS;
 using ::FILE _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/experimental/__simd/reference.h b/libcxx/include/experimental/__simd/reference.h
index 39f60d64f7b41f..c60c08b0ea459c 100644
--- a/libcxx/include/experimental/__simd/reference.h
+++ b/libcxx/include/experimental/__simd/reference.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
 #define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
 
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_assignable.h>
 #include <__type_traits/is_same.h>
 #include <__utility/declval.h>
diff --git a/libcxx/include/experimental/__simd/scalar.h b/libcxx/include/experimental/__simd/scalar.h
index 1add4653209ace..a2aeeb5cd0f54f 100644
--- a/libcxx/include/experimental/__simd/scalar.h
+++ b/libcxx/include/experimental/__simd/scalar.h
@@ -11,6 +11,7 @@
 #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H
 
 #include <__assert>
+#include <__type_traits/integral_constant.h>
 #include <cstddef>
 #include <experimental/__config>
 #include <experimental/__simd/declaration.h>
diff --git a/libcxx/include/experimental/__simd/simd.h b/libcxx/include/experimental/__simd/simd.h
index 37e334aad6da07..db0f9b39d9600c 100644
--- a/libcxx/include/experimental/__simd/simd.h
+++ b/libcxx/include/experimental/__simd/simd.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H
 #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H
 
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/remove_cvref.h>
 #include <__utility/forward.h>
diff --git a/libcxx/include/experimental/__simd/simd_mask.h b/libcxx/include/experimental/__simd/simd_mask.h
index fd6dee2e28ee91..d54d4898b718af 100644
--- a/libcxx/include/experimental/__simd/simd_mask.h
+++ b/libcxx/include/experimental/__simd/simd_mask.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H
 #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H
 
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_same.h>
 #include <cstddef>
 #include <experimental/__config>
diff --git a/libcxx/include/experimental/__simd/vec_ext.h b/libcxx/include/experimental/__simd/vec_ext.h
index 316866b84873dd..5787f237bb01ef 100644
--- a/libcxx/include/experimental/__simd/vec_ext.h
+++ b/libcxx/include/experimental/__simd/vec_ext.h
@@ -12,6 +12,7 @@
 
 #include <__assert>
 #include <__bit/bit_ceil.h>
+#include <__type_traits/integral_constant.h>
 #include <__utility/forward.h>
 #include <__utility/integer_sequence.h>
 #include <cstddef>
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index f193b5d95f49f5..60b0512b001d24 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -393,6 +393,11 @@ module std_cstdbool [system] {
 }
 module std_cstddef [system] {
   header "cstddef"
+  module byte         { header "__cstddef/byte.h" }
+  module max_align_t  { header "__cstddef/max_align_t.h" }
+  module nullptr_t    { header "__cstddef/nullptr_t.h" }
+  module ptrdiff_t    { header "__cstddef/ptrdiff_t.h" }
+  module size_t       { header "__cstddef/size_t.h" }
   export *
 }
 module std_cstdint [system] {
@@ -1430,6 +1435,7 @@ module std_private_iterator_iterator                [system] { header "__iterato
 module std_private_iterator_iterator_traits         [system] {
   header "__iterator/iterator_traits.h"
   export std_private_type_traits_is_primary_template
+  export std_private_type_traits_integral_constant
 }
 module std_private_iterator_iterator_with_data      [system] { header "__iterator/iterator_with_data.h" }
 module std_private_iterator_mergeable               [system] {
@@ -1836,7 +1842,10 @@ module std_private_tuple_tuple_like             [system] {
   export *
 }
 module std_private_tuple_tuple_like_ext         [system] { header "__tuple/tuple_like_ext.h" }
-module std_private_tuple_tuple_size             [system] { header "__tuple/tuple_size.h" }
+module std_private_tuple_tuple_size             [system] {
+  header "__tuple/tuple_size.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_tuple_tuple_types            [system] { header "__tuple/tuple_types.h" }
 
 module std_private_type_traits_add_const                                 [system] { header "__type_traits/add_const.h" }
@@ -1948,7 +1957,10 @@ module std_private_type_traits_is_implicitly_default_constructible       [system
   header "__type_traits/is_implicitly_default_constructible.h"
   export std_private_type_traits_integral_constant
 }
-module std_private_type_traits_is_integral                               [system] { header "__type_traits/is_integral.h" }
+module std_private_type_traits_is_integral                               [system] {
+  header "__type_traits/is_integral.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_type_traits_is_literal_type                           [system] { header "__type_traits/is_literal_type.h" }
 module std_private_type_traits_is_member_pointer                         [system] { header "__type_traits/is_member_pointer.h" }
 module std_private_type_traits_is_nothrow_assignable                     [system] { header "__type_traits/is_nothrow_assignable.h" }
@@ -1976,7 +1988,10 @@ module std_private_type_traits_is_primary_template                       [system
   header "__type_traits/is_primary_template.h"
   export std_private_type_traits_enable_if
 }
-module std_private_type_traits_is_reference                              [system] { header "__type_traits/is_reference.h" }
+module std_private_type_traits_is_reference                              [system] {
+  header "__type_traits/is_reference.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_type_traits_is_reference_wrapper                      [system] { header "__type_traits/is_reference_wrapper.h" }
 module std_private_type_traits_is_referenceable                          [system] { header "__type_traits/is_referenceable.h" }
 module std_private_type_traits_is_same                                   [system] {
@@ -1998,7 +2013,10 @@ module std_private_type_traits_is_swappable                              [system
 module std_private_type_traits_is_trivial                                [system] { header "__type_traits/is_trivial.h" }
 module std_private_type_traits_is_trivially_assignable                   [system] { header "__type_traits/is_trivially_assignable.h" }
 module std_private_type_traits_is_trivially_constructible                [system] { header "__type_traits/is_trivially_constructible.h" }
-module std_private_type_traits_is_trivially_copyable                     [system] { header "__type_traits/is_trivially_copyable.h" }
+module std_private_type_traits_is_trivially_copyable                     [system] {
+  header "__type_traits/is_trivially_copyable.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_type_traits_is_trivially_destructible                 [system] { header "__type_traits/is_trivially_destructible.h" }
 module std_private_type_traits_is_trivially_lexicographically_comparable [system] { header "__type_traits/is_trivially_lexicographically_comparable.h" }
 module std_private_type_traits_is_trivially_relocatable                  [system] { header "__type_traits/is_trivially_relocatable.h" }
@@ -2067,7 +2085,10 @@ module std_private_utility_exception_guard        [system] { header "__utility/e
 module std_private_utility_exchange               [system] { header "__utility/exchange.h" }
 module std_private_utility_forward                [system] { header "__utility/forward.h" }
 module std_private_utility_forward_like           [system] { header "__utility/forward_like.h" }
-module std_private_utility_in_place               [system] { header "__utility/in_place.h" }
+module std_private_utility_in_place               [system] {
+  header "__utility/in_place.h"
+  export std_private_type_traits_integral_constant
+}
 module std_private_utility_integer_sequence       [system] { header "__utility/integer_sequence.h" }
 module std_private_utility_is_pointer_in_range    [system] { header "__utility/is_pointer_in_range.h" }
 module std_private_utility_is_valid_range         [system] { header "__utility/is_valid_range.h" }
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 2727cad02fa99a..54e0b4cf5d6348 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -58,6 +58,7 @@ public:
 
 #include <__config>
 #include <__exception/exception.h>
+#include <__type_traits/integral_constant.h>
 #include <__type_traits/is_constant_evaluated.h>
 #include <__verbose_abort>
 #include <cstddef>
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index acf3485e644afb..69314ba7563197 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -600,7 +600,9 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 #include <__ranges/concepts.h>
 #include <__ranges/container_compatible_range.h>
 #include <__ranges/from_range.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_allocator.h>
+#include <__type_traits/is_integral.h>
 #include <__type_traits/type_identity.h>
 #include <__utility/forward.h>
 #include <stdexcept>
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index d11ceacba81433..fb50f78a02941c 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -548,7 +548,9 @@ template <class Value, class Hash, class Pred, class Alloc>
 #include <__ranges/concepts.h>
 #include <__ranges/container_compatible_range.h>
 #include <__ranges/from_range.h>
+#include <__type_traits/enable_if.h>
 #include <__type_traits/is_allocator.h>
+#include <__type_traits/is_integral.h>
 #include <__utility/forward.h>
 #include <version>
 
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index fd2cd7f1c2d961..ed83983b69f852 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -234,7 +234,6 @@ expected cstddef
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iosfwd
 experimental/iterator iterator
 experimental/iterator type_traits
@@ -921,7 +920,6 @@ tuple type_traits
 tuple typeinfo
 tuple utility
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 04122fd0f4571a..ba8f9a3f4163ae 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -235,7 +235,6 @@ expected cstddef
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iosfwd
 experimental/iterator iterator
 experimental/iterator type_traits
@@ -928,7 +927,6 @@ tuple type_traits
 tuple typeinfo
 tuple utility
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 42c742bead0c1f..c0f3f48991add4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -236,7 +236,6 @@ expected cstddef
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iosfwd
 experimental/iterator iterator
 experimental/iterator type_traits
@@ -931,7 +930,6 @@ tuple type_traits
 tuple typeinfo
 tuple utility
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index bc0659127d4bf5..270d28b2d3cde4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -236,7 +236,6 @@ expected cstddef
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iosfwd
 experimental/iterator iterator
 experimental/iterator type_traits
@@ -932,7 +931,6 @@ tuple type_traits
 tuple typeinfo
 tuple utility
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index fed0944f0219c4..9732d3c11dce02 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -244,7 +244,6 @@ expected cstddef
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iosfwd
 experimental/iterator iterator
 experimental/iterator type_traits
@@ -939,7 +938,6 @@ tuple type_traits
 tuple typeinfo
 tuple utility
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 53f99384a7f573..e41ddfce63422e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -158,7 +158,6 @@ expected cstdint
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iterator
 experimental/memory cstddef
 experimental/memory cstdint
@@ -650,7 +649,6 @@ tuple compare
 tuple cstddef
 tuple cstdint
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 53f99384a7f573..e41ddfce63422e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -158,7 +158,6 @@ expected cstdint
 expected initializer_list
 expected new
 expected version
-experimental/iterator cstddef
 experimental/iterator iterator
 experimental/memory cstddef
 experimental/memory cstdint
@@ -650,7 +649,6 @@ tuple compare
 tuple cstddef
 tuple cstdint
 tuple version
-type_traits cstddef
 type_traits cstdint
 type_traits version
 typeindex compare
diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp
index 5e37db95ab090e..1ab1aa60ab826f 100644
--- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <type_traits>
 
diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp
index 38a46fcc122274..f243e9d1f63b50 100644
--- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_floor.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp
index baf2032a4a1f00..e6a0cfb9d11e02 100644
--- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_width.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp
index 81dca301e21fb3..a1088218a35f01 100644
--- a/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bit.pow.two/has_single_bit.pass.cpp
@@ -15,6 +15,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp
index 92268cf563b471..82931162b4f39f 100644
--- a/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.count/countl_one.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp
index 9d5d361662e8c8..20e0eff91b253c 100644
--- a/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.count/countl_zero.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp
index 63b60640ac0480..1fedc4f8a5386e 100644
--- a/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.count/countr_one.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp
index 1df1d883a12e1f..4221b86fe1cc66 100644
--- a/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.count/countr_zero.pass.cpp
@@ -17,6 +17,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp b/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp
index 588c5e0cf7af27..a7c5c43a4e2c2e 100644
--- a/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.count/popcount.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
index 16eabbd2a5a4de..72e412772fb081 100644
--- a/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.rot/rotl.pass.cpp
@@ -15,6 +15,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>
diff --git a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
index 53405588266f74..fc0fff60394e31 100644
--- a/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bitops.rot/rotr.pass.cpp
@@ -15,6 +15,7 @@
 
 #include <bit>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <limits>
 #include <type_traits>



More information about the libcxx-commits mailing list