[libcxx-commits] [libcxx] [libc++][NFC] Granularize includes of <optional> (PR #213433)

Michael G. Kazakov via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 1 08:42:33 PDT 2026


https://github.com/mikekazakov updated https://github.com/llvm/llvm-project/pull/213433

>From 08470163efcf9d7fada899fef27cfc64947d169c Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sat, 1 Aug 2026 12:24:00 +0100
Subject: [PATCH] Granularize includes of <optional>

---
 libcxx/include/__algorithm/ranges_fold.h      |  3 +-
 libcxx/include/__format/format_context.h      |  3 +-
 libcxx/include/__format/format_functions.h    | 58 ++++++++++---------
 libcxx/include/__node_handle                  |  6 +-
 libcxx/include/__pstl/backends/default.h      |  4 +-
 libcxx/include/__pstl/backends/libdispatch.h  |  4 +-
 libcxx/include/__pstl/backends/serial.h       |  2 +-
 libcxx/include/__pstl/backends/std_thread.h   |  3 +-
 libcxx/include/__pstl/cpu_algos/any_of.h      |  3 +-
 libcxx/include/__pstl/cpu_algos/fill.h        |  2 +-
 libcxx/include/__pstl/cpu_algos/find_if.h     |  3 +-
 libcxx/include/__pstl/cpu_algos/for_each.h    |  2 +-
 libcxx/include/__pstl/cpu_algos/merge.h       |  3 +-
 libcxx/include/__pstl/cpu_algos/mismatch.h    |  3 +-
 libcxx/include/__pstl/cpu_algos/stable_sort.h |  2 +-
 libcxx/include/__pstl/cpu_algos/transform.h   |  3 +-
 .../__pstl/cpu_algos/transform_reduce.h       |  5 +-
 libcxx/include/__pstl/handle_exception.h      |  4 +-
 libcxx/include/__ranges/join_view.h           |  7 ++-
 libcxx/include/__ranges/movable_box.h         |  6 +-
 .../include/__ranges/non_propagating_cache.h  |  4 +-
 .../test/libcxx/transitive_includes/cxx23.csv | 17 ------
 .../test/libcxx/transitive_includes/cxx26.csv | 17 ------
 23 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/libcxx/include/__algorithm/ranges_fold.h b/libcxx/include/__algorithm/ranges_fold.h
index 87579b264296a..27e042395dad0 100644
--- a/libcxx/include/__algorithm/ranges_fold.h
+++ b/libcxx/include/__algorithm/ranges_fold.h
@@ -25,14 +25,15 @@
 #include <__iterator/next.h>
 #include <__iterator/prev.h>
 #include <__iterator/reverse_iterator.h>
+#include <__optional/optional.h>
 #include <__ranges/access.h>
 #include <__ranges/concepts.h>
 #include <__ranges/dangling.h>
 #include <__type_traits/decay.h>
 #include <__type_traits/invoke.h>
 #include <__utility/forward.h>
+#include <__utility/in_place.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index cf3131b80e52f..aab16d0dcae3f 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -26,7 +26,8 @@
 
 #if _LIBCPP_HAS_LOCALIZATION
 #  include <__locale>
-#  include <optional>
+#  include <__optional/nullopt_t.h>
+#  include <__optional/optional.h>
 #endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index b58e487d7511e..50a9ace7daf30 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -36,9 +36,10 @@
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
 #include <__iterator/iterator_traits.h> // iter_value_t
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__variant/monostate.h>
 #include <array>
-#include <optional>
 #include <string>
 #include <string_view>
 
@@ -406,9 +407,10 @@ using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
 
 template <class _OutIt, class _CharT, class _FormatOutIt>
   requires(output_iterator<_OutIt, const _CharT&>)
-_LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(_OutIt __out_it,
-                                          basic_string_view<_CharT> __fmt,
-                                          basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
+_LIBCPP_HIDE_FROM_ABI
+_OutIt __vformat_to(_OutIt __out_it,
+                    basic_string_view<_CharT> __fmt,
+                    basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
   if constexpr (same_as<_OutIt, _FormatOutIt>)
     return std::__format::__vformat_to(
         basic_format_parse_context{__fmt, __args.__size()}, std::__format_context_create(std::move(__out_it), __args));
@@ -430,22 +432,22 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, s
 
 #  if _LIBCPP_HAS_WIDE_CHARACTERS
 template <output_iterator<const wchar_t&> _OutIt>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
+_LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
   return std::__vformat_to(std::move(__out_it), __fmt, __args);
 }
 #  endif
 
 template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
+_LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI _OutIt format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat_to(std::move(__out_it), __fmt.get(), std::make_format_args(__args...));
 }
 
 #  if _LIBCPP_HAS_WIDE_CHARACTERS
 template <output_iterator<const wchar_t&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
+_LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI _OutIt format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat_to(std::move(__out_it), __fmt.get(), std::make_wformat_args(__args...));
 }
 #  endif
@@ -516,15 +518,15 @@ vformat(wstring_view __fmt, wformat_args __args) {
 #  endif
 
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
-format(format_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI string format(format_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat(__fmt.get(), std::make_format_args(__args...));
 }
 
 #  if _LIBCPP_HAS_WIDE_CHARACTERS
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
-format(wformat_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI wstring format(wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat(__fmt.get(), std::make_wformat_args(__args...));
 }
 #  endif
@@ -571,8 +573,8 @@ formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
 
 #  if _LIBCPP_HAS_WIDE_CHARACTERS
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
-formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI size_t formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_wformat_args(__args...)});
 }
 #  endif
@@ -606,22 +608,22 @@ vformat_to(_OutIt __out_it, locale __loc, string_view __fmt, format_args __args)
 
 #    if _LIBCPP_HAS_WIDE_CHARACTERS
 template <output_iterator<const wchar_t&> _OutIt>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-vformat_to(_OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
+_LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
   return std::__vformat_to(std::move(__out_it), std::move(__loc), __fmt, __args);
 }
 #    endif
 
 template <output_iterator<const char&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI
+_OutIt format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat_to(std::move(__out_it), std::move(__loc), __fmt.get(), std::make_format_args(__args...));
 }
 
 #    if _LIBCPP_HAS_WIDE_CHARACTERS
 template <output_iterator<const wchar_t&> _OutIt, class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
-format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI
+_OutIt format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat_to(std::move(__out_it), std::move(__loc), __fmt.get(), std::make_wformat_args(__args...));
 }
 #    endif
@@ -649,15 +651,15 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
 #    endif
 
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
-format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI string format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...));
 }
 
 #    if _LIBCPP_HAS_WIDE_CHARACTERS
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
-format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI wstring format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::vformat(std::move(__loc), __fmt.get(), std::make_wformat_args(__args...));
 }
 #    endif
@@ -709,8 +711,8 @@ formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
 
 #    if _LIBCPP_HAS_WIDE_CHARACTERS
 template <class... _Args>
-[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
-formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+[[nodiscard]] _LIBCPP_ALWAYS_INLINE
+_LIBCPP_HIDE_FROM_ABI size_t formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
   return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_wformat_args(__args...)});
 }
 #    endif
diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle
index 993283cc926da..44ce7cafec0d8 100644
--- a/libcxx/include/__node_handle
+++ b/libcxx/include/__node_handle
@@ -62,9 +62,13 @@ public:
 #include <__config>
 #include <__memory/allocator_traits.h>
 #include <__memory/pointer_traits.h>
+#include <__optional/comparison.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__type_traits/is_specialization.h>
+#include <__type_traits/remove_const.h>
 #include <__utility/exchange.h>
-#include <optional>
+#include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/backends/default.h b/libcxx/include/__pstl/backends/default.h
index df287bdb67dc1..53e723d7bc6d2 100644
--- a/libcxx/include/__pstl/backends/default.h
+++ b/libcxx/include/__pstl/backends/default.h
@@ -27,13 +27,15 @@
 #include <__iterator/next.h>
 #include <__iterator/prev.h>
 #include <__iterator/reverse_iterator.h>
+#include <__optional/comparison.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/dispatch.h>
 #include <__type_traits/desugars_to.h>
 #include <__utility/empty.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/backends/libdispatch.h b/libcxx/include/__pstl/backends/libdispatch.h
index 5e89c6fe31cd8..6b77940afbad4 100644
--- a/libcxx/include/__pstl/backends/libdispatch.h
+++ b/libcxx/include/__pstl/backends/libdispatch.h
@@ -21,6 +21,7 @@
 #include <__atomic/atomic.h>
 #include <__config>
 #include <__cstddef/ptrdiff_t.h>
+#include <__cstddef/size_t.h>
 #include <__exception/terminate.h>
 #include <__iterator/iterator_traits.h>
 #include <__iterator/move_iterator.h>
@@ -30,6 +31,8 @@
 #include <__memory/unique_ptr.h>
 #include <__new/exceptions.h>
 #include <__numeric/reduce.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/any_of.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
@@ -45,7 +48,6 @@
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>
-#include <optional>
 
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
diff --git a/libcxx/include/__pstl/backends/serial.h b/libcxx/include/__pstl/backends/serial.h
index d90022ee37145..fe4b9da14dcf5 100644
--- a/libcxx/include/__pstl/backends/serial.h
+++ b/libcxx/include/__pstl/backends/serial.h
@@ -18,11 +18,11 @@
 #include <__algorithm/transform.h>
 #include <__config>
 #include <__numeric/transform_reduce.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__utility/empty.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/backends/std_thread.h b/libcxx/include/__pstl/backends/std_thread.h
index 93935d22b9442..07610ee880a88 100644
--- a/libcxx/include/__pstl/backends/std_thread.h
+++ b/libcxx/include/__pstl/backends/std_thread.h
@@ -10,6 +10,8 @@
 #define _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/any_of.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
@@ -23,7 +25,6 @@
 #include <__pstl/cpu_algos/transform_reduce.h>
 #include <__utility/empty.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/any_of.h b/libcxx/include/__pstl/cpu_algos/any_of.h
index 803db7974eca7..cb161542cbc5e 100644
--- a/libcxx/include/__pstl/cpu_algos/any_of.h
+++ b/libcxx/include/__pstl/cpu_algos/any_of.h
@@ -15,13 +15,14 @@
 #include <__atomic/memory_order.h>
 #include <__config>
 #include <__iterator/concepts.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>
 #include <cstdint>
-#include <optional>
 
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
diff --git a/libcxx/include/__pstl/cpu_algos/fill.h b/libcxx/include/__pstl/cpu_algos/fill.h
index 3e5936589a6a6..83993669014e8 100644
--- a/libcxx/include/__pstl/cpu_algos/fill.h
+++ b/libcxx/include/__pstl/cpu_algos/fill.h
@@ -13,11 +13,11 @@
 #include <__assert>
 #include <__config>
 #include <__iterator/concepts.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/empty.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/find_if.h b/libcxx/include/__pstl/cpu_algos/find_if.h
index aae64b66eb0c0..cf54c4b0d4f52 100644
--- a/libcxx/include/__pstl/cpu_algos/find_if.h
+++ b/libcxx/include/__pstl/cpu_algos/find_if.h
@@ -16,12 +16,13 @@
 #include <__functional/operations.h>
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/for_each.h b/libcxx/include/__pstl/cpu_algos/for_each.h
index cec719bc47b88..908f82f01e6c8 100644
--- a/libcxx/include/__pstl/cpu_algos/for_each.h
+++ b/libcxx/include/__pstl/cpu_algos/for_each.h
@@ -13,11 +13,11 @@
 #include <__assert>
 #include <__config>
 #include <__iterator/concepts.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/empty.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/merge.h b/libcxx/include/__pstl/cpu_algos/merge.h
index a9069ca51de2f..7628f47e40e04 100644
--- a/libcxx/include/__pstl/cpu_algos/merge.h
+++ b/libcxx/include/__pstl/cpu_algos/merge.h
@@ -13,11 +13,12 @@
 #include <__assert>
 #include <__config>
 #include <__iterator/concepts.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/mismatch.h b/libcxx/include/__pstl/cpu_algos/mismatch.h
index 3d702b03d3afe..1aaec3e047c0b 100644
--- a/libcxx/include/__pstl/cpu_algos/mismatch.h
+++ b/libcxx/include/__pstl/cpu_algos/mismatch.h
@@ -15,13 +15,14 @@
 #include <__functional/operations.h>
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__pstl/cpu_algos/find_if.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
 #include <__utility/pair.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/stable_sort.h b/libcxx/include/__pstl/cpu_algos/stable_sort.h
index 5afdd3fd629ba..d8d08325564e4 100644
--- a/libcxx/include/__pstl/cpu_algos/stable_sort.h
+++ b/libcxx/include/__pstl/cpu_algos/stable_sort.h
@@ -11,11 +11,11 @@
 
 #include <__algorithm/stable_sort.h>
 #include <__config>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/empty.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/transform.h b/libcxx/include/__pstl/cpu_algos/transform.h
index 30d117d754b31..61630ea8f9d47 100644
--- a/libcxx/include/__pstl/cpu_algos/transform.h
+++ b/libcxx/include/__pstl/cpu_algos/transform.h
@@ -14,11 +14,12 @@
 #include <__config>
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/cpu_algos/transform_reduce.h b/libcxx/include/__pstl/cpu_algos/transform_reduce.h
index edfb28b4466fc..ecf4b0a446251 100644
--- a/libcxx/include/__pstl/cpu_algos/transform_reduce.h
+++ b/libcxx/include/__pstl/cpu_algos/transform_reduce.h
@@ -11,16 +11,19 @@
 
 #include <__assert>
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
 #include <__numeric/transform_reduce.h>
+#include <__optional/optional.h>
 #include <__pstl/backend_fwd.h>
 #include <__pstl/cpu_algos/cpu_traits.h>
 #include <__type_traits/desugars_to.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/invoke.h>
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/is_execution_policy.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__pstl/handle_exception.h b/libcxx/include/__pstl/handle_exception.h
index 3b5fca86902b0..303371e8ce435 100644
--- a/libcxx/include/__pstl/handle_exception.h
+++ b/libcxx/include/__pstl/handle_exception.h
@@ -11,9 +11,11 @@
 
 #include <__config>
 #include <__new/exceptions.h>
+#include <__optional/comparison.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__ranges/join_view.h b/libcxx/include/__ranges/join_view.h
index 4f3f8d1c1e5b4..def920648e67f 100644
--- a/libcxx/include/__ranges/join_view.h
+++ b/libcxx/include/__ranges/join_view.h
@@ -23,6 +23,8 @@
 #include <__iterator/iterator_with_data.h>
 #include <__iterator/segmented_iterator.h>
 #include <__memory/addressof.h>
+#include <__optional/comparison.h>
+#include <__optional/optional.h>
 #include <__ranges/access.h>
 #include <__ranges/all.h>
 #include <__ranges/concepts.h>
@@ -31,11 +33,14 @@
 #include <__ranges/range_adaptor.h>
 #include <__ranges/view_interface.h>
 #include <__type_traits/common_type.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_reference.h>
 #include <__type_traits/maybe_const.h>
+#include <__type_traits/remove_cvref.h>
 #include <__utility/as_lvalue.h>
 #include <__utility/empty.h>
 #include <__utility/forward.h>
-#include <optional>
+#include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__ranges/movable_box.h b/libcxx/include/__ranges/movable_box.h
index 5a456cc3a1b66..117111698c04a 100644
--- a/libcxx/include/__ranges/movable_box.h
+++ b/libcxx/include/__ranges/movable_box.h
@@ -16,9 +16,13 @@
 #include <__config>
 #include <__memory/addressof.h>
 #include <__memory/construct_at.h>
+#include <__optional/optional.h>
+#include <__type_traits/is_constructible.h>
 #include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_object.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
 #include <__utility/move.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__ranges/non_propagating_cache.h b/libcxx/include/__ranges/non_propagating_cache.h
index beae13a98e9e3..9d71827c94caa 100644
--- a/libcxx/include/__ranges/non_propagating_cache.h
+++ b/libcxx/include/__ranges/non_propagating_cache.h
@@ -14,8 +14,10 @@
 #include <__iterator/concepts.h>        // indirectly_readable
 #include <__iterator/iterator_traits.h> // iter_reference_t
 #include <__memory/addressof.h>
+#include <__optional/nullopt_t.h>
+#include <__optional/optional.h>
+#include <__type_traits/is_object.h>
 #include <__utility/forward.h>
-#include <optional>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 2acd8ef28d907..bb199e29a2a9d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -9,7 +9,6 @@ algorithm cwctype
 algorithm initializer_list
 algorithm iosfwd
 algorithm limits
-algorithm optional
 algorithm ratio
 algorithm tuple
 algorithm version
@@ -123,7 +122,6 @@ chrono iosfwd
 chrono istream
 chrono limits
 chrono locale
-chrono optional
 chrono ratio
 chrono sstream
 chrono stdexcept
@@ -349,7 +347,6 @@ flat_map cwchar
 flat_map cwctype
 flat_map initializer_list
 flat_map limits
-flat_map optional
 flat_map stdexcept
 flat_map tuple
 flat_map version
@@ -362,7 +359,6 @@ flat_set cwchar
 flat_set cwctype
 flat_set initializer_list
 flat_set limits
-flat_set optional
 flat_set stdexcept
 flat_set tuple
 flat_set version
@@ -385,7 +381,6 @@ format initializer_list
 format ios
 format iosfwd
 format limits
-format optional
 format ratio
 format stdexcept
 format streambuf
@@ -444,7 +439,6 @@ functional cwchar
 functional cwctype
 functional initializer_list
 functional limits
-functional optional
 functional stdexcept
 functional tuple
 functional typeinfo
@@ -556,7 +550,6 @@ iostream iosfwd
 iostream istream
 iostream limits
 iostream locale
-iostream optional
 iostream ostream
 iostream print
 iostream ratio
@@ -661,7 +654,6 @@ map cwchar
 map cwctype
 map initializer_list
 map limits
-map optional
 map stdexcept
 map tuple
 map version
@@ -718,7 +710,6 @@ numeric cwchar
 numeric cwctype
 numeric initializer_list
 numeric limits
-numeric optional
 numeric ratio
 numeric tuple
 numeric version
@@ -750,7 +741,6 @@ ostream ios
 ostream iosfwd
 ostream limits
 ostream locale
-ostream optional
 ostream print
 ostream ratio
 ostream stdexcept
@@ -781,7 +771,6 @@ print initializer_list
 print ios
 print iosfwd
 print limits
-print optional
 print ratio
 print stdexcept
 print streambuf
@@ -829,7 +818,6 @@ random initializer_list
 random iosfwd
 random limits
 random numeric
-random optional
 random ratio
 random stdexcept
 random string
@@ -849,7 +837,6 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
-ranges optional
 ranges span
 ranges stdexcept
 ranges tuple
@@ -903,7 +890,6 @@ set cwchar
 set cwctype
 set initializer_list
 set limits
-set optional
 set tuple
 set version
 shared_mutex cerrno
@@ -1073,7 +1059,6 @@ syncstream iosfwd
 syncstream limits
 syncstream locale
 syncstream map
-syncstream optional
 syncstream ostream
 syncstream print
 syncstream ratio
@@ -1153,7 +1138,6 @@ unordered_map cstdint
 unordered_map cstring
 unordered_map initializer_list
 unordered_map limits
-unordered_map optional
 unordered_map stdexcept
 unordered_map tuple
 unordered_map version
@@ -1162,7 +1146,6 @@ unordered_set cstdint
 unordered_set cstring
 unordered_set initializer_list
 unordered_set limits
-unordered_set optional
 unordered_set tuple
 unordered_set version
 utility compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 9b047ca3d97db..caf94dc4b2ca5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -9,7 +9,6 @@ algorithm cwctype
 algorithm initializer_list
 algorithm iosfwd
 algorithm limits
-algorithm optional
 algorithm ratio
 algorithm tuple
 algorithm version
@@ -117,7 +116,6 @@ chrono ios
 chrono iosfwd
 chrono istream
 chrono limits
-chrono optional
 chrono ratio
 chrono sstream
 chrono stdexcept
@@ -331,7 +329,6 @@ flat_map cwchar
 flat_map cwctype
 flat_map initializer_list
 flat_map limits
-flat_map optional
 flat_map stdexcept
 flat_map tuple
 flat_map version
@@ -344,7 +341,6 @@ flat_set cwchar
 flat_set cwctype
 flat_set initializer_list
 flat_set limits
-flat_set optional
 flat_set stdexcept
 flat_set tuple
 flat_set version
@@ -365,7 +361,6 @@ format initializer_list
 format ios
 format iosfwd
 format limits
-format optional
 format stdexcept
 format streambuf
 format string
@@ -419,7 +414,6 @@ functional cwchar
 functional cwctype
 functional initializer_list
 functional limits
-functional optional
 functional stdexcept
 functional tuple
 functional typeinfo
@@ -512,7 +506,6 @@ iostream ios
 iostream iosfwd
 iostream istream
 iostream limits
-iostream optional
 iostream ostream
 iostream print
 iostream stdexcept
@@ -611,7 +604,6 @@ map cwchar
 map cwctype
 map initializer_list
 map limits
-map optional
 map stdexcept
 map tuple
 map version
@@ -667,7 +659,6 @@ numeric cwchar
 numeric cwctype
 numeric initializer_list
 numeric limits
-numeric optional
 numeric ratio
 numeric tuple
 numeric version
@@ -696,7 +687,6 @@ ostream initializer_list
 ostream ios
 ostream iosfwd
 ostream limits
-ostream optional
 ostream print
 ostream stdexcept
 ostream streambuf
@@ -724,7 +714,6 @@ print initializer_list
 print ios
 print iosfwd
 print limits
-print optional
 print stdexcept
 print streambuf
 print string
@@ -765,7 +754,6 @@ random initializer_list
 random iosfwd
 random limits
 random numeric
-random optional
 random ratio
 random stdexcept
 random string
@@ -785,7 +773,6 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
-ranges optional
 ranges span
 ranges stdexcept
 ranges tuple
@@ -837,7 +824,6 @@ set cwchar
 set cwctype
 set initializer_list
 set limits
-set optional
 set tuple
 set version
 shared_mutex cerrno
@@ -996,7 +982,6 @@ syncstream ios
 syncstream iosfwd
 syncstream limits
 syncstream map
-syncstream optional
 syncstream ostream
 syncstream print
 syncstream ratio
@@ -1085,7 +1070,6 @@ unordered_map cstdint
 unordered_map cstring
 unordered_map initializer_list
 unordered_map limits
-unordered_map optional
 unordered_map stdexcept
 unordered_map tuple
 unordered_map version
@@ -1094,7 +1078,6 @@ unordered_set cstdint
 unordered_set cstring
 unordered_set initializer_list
 unordered_set limits
-unordered_set optional
 unordered_set tuple
 unordered_set version
 utility compare



More information about the libcxx-commits mailing list