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

Michael G. Kazakov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 2 05:32:43 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 1/3] 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

>From bf241bf3707358cd6a4d8dfed37511c539bac938 Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sun, 2 Aug 2026 13:31:55 +0100
Subject: [PATCH 2/3] Include <optional> before C++26 in places where it was
 previously provided

---
 libcxx/include/algorithm                      |  4 ++
 libcxx/include/chrono                         |  4 ++
 libcxx/include/flat_map                       |  4 ++
 libcxx/include/flat_set                       |  4 ++
 libcxx/include/format                         |  4 ++
 libcxx/include/functional                     |  4 ++
 libcxx/include/iostream                       |  3 +
 libcxx/include/map                            |  4 ++
 libcxx/include/numeric                        |  4 ++
 libcxx/include/ostream                        |  3 +
 libcxx/include/print                          |  3 +
 libcxx/include/random                         |  4 ++
 libcxx/include/ranges                         |  4 ++
 libcxx/include/set                            |  4 ++
 libcxx/include/syncstream                     |  4 ++
 libcxx/include/unordered_map                  |  4 ++
 libcxx/include/unordered_set                  |  4 ++
 .../test/libcxx/transitive_includes/cxx03.csv | 62 +++++++++++++++++++
 .../test/libcxx/transitive_includes/cxx11.csv | 62 +++++++++++++++++++
 .../test/libcxx/transitive_includes/cxx14.csv | 62 +++++++++++++++++++
 .../test/libcxx/transitive_includes/cxx17.csv | 62 +++++++++++++++++++
 .../test/libcxx/transitive_includes/cxx20.csv | 44 +++++++++++++
 .../test/libcxx/transitive_includes/cxx23.csv | 17 +++++
 23 files changed, 374 insertions(+)

diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index a0c632edbcbda..c9627be133e94 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -2121,6 +2121,10 @@ template <class BidirectionalIterator, class Compare>
 #    include <type_traits>
 #    include <utility>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_ALGORITHM
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 8cc6b9bb883b9..2c8274a23db35 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -1172,6 +1172,10 @@ namespace std {
 #      include <ostream>
 #    endif
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_CHRONO
diff --git a/libcxx/include/flat_map b/libcxx/include/flat_map
index f2566c7745c88..48e00a35754fb 100644
--- a/libcxx/include/flat_map
+++ b/libcxx/include/flat_map
@@ -739,6 +739,10 @@ namespace std {
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    pragma GCC system_header
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_FLAT_MAP
diff --git a/libcxx/include/flat_set b/libcxx/include/flat_set
index f41e825dbd77e..72f5b7fe8fddd 100644
--- a/libcxx/include/flat_set
+++ b/libcxx/include/flat_set
@@ -615,6 +615,10 @@ namespace std {
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    pragma GCC system_header
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_FLAT_SET
diff --git a/libcxx/include/format b/libcxx/include/format
index fcfb70d78c2a1..fde3e7d7cecbb 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -262,6 +262,10 @@ namespace std {
 #      include <cwchar>
 #    endif
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_FORMAT
diff --git a/libcxx/include/functional b/libcxx/include/functional
index df79d616a57e2..30a5f9496c546 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -615,6 +615,10 @@ POLICY:  For non-variadic implementations, the number of arguments is limited
 #  if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER == 23
 #    include <__vector/vector.h>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_FUNCTIONAL
diff --git a/libcxx/include/iostream b/libcxx/include/iostream
index 0e83f0002ae6e..52b69808011d4 100644
--- a/libcxx/include/iostream
+++ b/libcxx/include/iostream
@@ -67,6 +67,9 @@ extern _LIBCPP_EXPORTED_FROM_ABI wostream wclog;
 
 _LIBCPP_END_NAMESPACE_STD
 
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_IOSTREAM
diff --git a/libcxx/include/map b/libcxx/include/map
index d51daa128eada..d5017283c7e3e 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -2346,6 +2346,10 @@ _LIBCPP_POP_MACROS
 #    include <type_traits>
 #    include <utility>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_MAP
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 7078108773ebd..c5454f71b6540 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -207,6 +207,10 @@ constexpr T saturating_cast(U x) noexcept;                    // freestanding, S
 #    include <optional>
 #    include <type_traits>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_NUMERIC
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 3fa9a3a5437e1..9efa8c34c71f4 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -210,6 +210,9 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 #    include <locale>
 #  endif
 
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_OSTREAM
diff --git a/libcxx/include/print b/libcxx/include/print
index a9c4ee686f5f9..17693057b5782 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -382,6 +382,9 @@ _LIBCPP_END_NAMESPACE_STD
 
 #  endif // _LIBCPP_STD_VER >= 23
 
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_PRINT
diff --git a/libcxx/include/random b/libcxx/include/random
index 05decfc69c923..11c384703f418 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -1741,6 +1741,10 @@ class piecewise_linear_distribution
 #    include <type_traits>
 #    include <vector>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_RANDOM
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index d82a41942327b..e1924bb4c3607 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -550,6 +550,10 @@ namespace std {
 #    include <iosfwd>
 #    include <type_traits>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_RANGES
diff --git a/libcxx/include/set b/libcxx/include/set
index 59aef4a42b428..518dbfd05ef5a 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -1708,6 +1708,10 @@ _LIBCPP_POP_MACROS
 #    include <stdexcept>
 #    include <type_traits>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_SET
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index ca1a89e6bfe0d..961d95705c50c 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -519,6 +519,10 @@ _LIBCPP_END_NAMESPACE_STD
 _LIBCPP_POP_MACROS
 
 #  endif // _LIBCPP_HAS_LOCALIZATION
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif   // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_SYNCSTREAM
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index b8b160cd892d4..c58bc7ecce4ac 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -2390,6 +2390,10 @@ _LIBCPP_POP_MACROS
 #    include <iterator>
 #    include <type_traits>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_UNORDERED_MAP
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index 10f8b730b842b..57d0cf679cf85 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -1845,6 +1845,10 @@ _LIBCPP_POP_MACROS
 #    include <stdexcept>
 #    include <type_traits>
 #  endif
+
+#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+#    include <optional>
+#  endif
 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
 
 #endif // _LIBCPP_UNORDERED_SET
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index b0b58724e64ab..cdad346c3fc41 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -687,21 +687,65 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
+flat_map atomic
+flat_map cctype
+flat_map climits
 flat_map cmath
 flat_map compare
+flat_map concepts
 flat_map cstddef
 flat_map cstdint
+flat_map cstdio
+flat_map cstdlib
+flat_map cstring
+flat_map ctime
+flat_map cwchar
+flat_map cwctype
+flat_map exception
 flat_map initializer_list
+flat_map iosfwd
+flat_map iterator
 flat_map limits
+flat_map memory
+flat_map new
+flat_map optional
+flat_map ratio
+flat_map stdexcept
+flat_map tuple
 flat_map type_traits
+flat_map typeinfo
+flat_map utility
+flat_map variant
 flat_map version
+flat_set atomic
+flat_set cctype
+flat_set climits
 flat_set cmath
 flat_set compare
+flat_set concepts
 flat_set cstddef
 flat_set cstdint
+flat_set cstdio
+flat_set cstdlib
+flat_set cstring
+flat_set ctime
+flat_set cwchar
+flat_set cwctype
+flat_set exception
 flat_set initializer_list
+flat_set iosfwd
+flat_set iterator
 flat_set limits
+flat_set memory
+flat_set new
+flat_set optional
+flat_set ratio
+flat_set stdexcept
+flat_set tuple
 flat_set type_traits
+flat_set typeinfo
+flat_set utility
+flat_set variant
 flat_set version
 format algorithm
 format array
@@ -1705,7 +1749,9 @@ random utility
 random variant
 random vector
 random version
+ranges atomic
 ranges cctype
+ranges climits
 ranges cmath
 ranges compare
 ranges concepts
@@ -1714,6 +1760,7 @@ ranges cstdint
 ranges cstdio
 ranges cstdlib
 ranges cstring
+ranges ctime
 ranges cwchar
 ranges cwctype
 ranges exception
@@ -1721,7 +1768,11 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
+ranges memory
 ranges new
+ranges optional
+ranges ratio
+ranges stdexcept
 ranges tuple
 ranges type_traits
 ranges typeinfo
@@ -2066,8 +2117,19 @@ stdexcept new
 stdexcept type_traits
 stdexcept typeinfo
 stdexcept version
+stop_token atomic
+stop_token climits
+stop_token cmath
+stop_token compare
 stop_token cstddef
+stop_token cstdint
+stop_token cstdlib
+stop_token cstring
+stop_token ctime
 stop_token iosfwd
+stop_token limits
+stop_token ratio
+stop_token type_traits
 stop_token version
 streambuf algorithm
 streambuf atomic
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index b0b58724e64ab..cdad346c3fc41 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -687,21 +687,65 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
+flat_map atomic
+flat_map cctype
+flat_map climits
 flat_map cmath
 flat_map compare
+flat_map concepts
 flat_map cstddef
 flat_map cstdint
+flat_map cstdio
+flat_map cstdlib
+flat_map cstring
+flat_map ctime
+flat_map cwchar
+flat_map cwctype
+flat_map exception
 flat_map initializer_list
+flat_map iosfwd
+flat_map iterator
 flat_map limits
+flat_map memory
+flat_map new
+flat_map optional
+flat_map ratio
+flat_map stdexcept
+flat_map tuple
 flat_map type_traits
+flat_map typeinfo
+flat_map utility
+flat_map variant
 flat_map version
+flat_set atomic
+flat_set cctype
+flat_set climits
 flat_set cmath
 flat_set compare
+flat_set concepts
 flat_set cstddef
 flat_set cstdint
+flat_set cstdio
+flat_set cstdlib
+flat_set cstring
+flat_set ctime
+flat_set cwchar
+flat_set cwctype
+flat_set exception
 flat_set initializer_list
+flat_set iosfwd
+flat_set iterator
 flat_set limits
+flat_set memory
+flat_set new
+flat_set optional
+flat_set ratio
+flat_set stdexcept
+flat_set tuple
 flat_set type_traits
+flat_set typeinfo
+flat_set utility
+flat_set variant
 flat_set version
 format algorithm
 format array
@@ -1705,7 +1749,9 @@ random utility
 random variant
 random vector
 random version
+ranges atomic
 ranges cctype
+ranges climits
 ranges cmath
 ranges compare
 ranges concepts
@@ -1714,6 +1760,7 @@ ranges cstdint
 ranges cstdio
 ranges cstdlib
 ranges cstring
+ranges ctime
 ranges cwchar
 ranges cwctype
 ranges exception
@@ -1721,7 +1768,11 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
+ranges memory
 ranges new
+ranges optional
+ranges ratio
+ranges stdexcept
 ranges tuple
 ranges type_traits
 ranges typeinfo
@@ -2066,8 +2117,19 @@ stdexcept new
 stdexcept type_traits
 stdexcept typeinfo
 stdexcept version
+stop_token atomic
+stop_token climits
+stop_token cmath
+stop_token compare
 stop_token cstddef
+stop_token cstdint
+stop_token cstdlib
+stop_token cstring
+stop_token ctime
 stop_token iosfwd
+stop_token limits
+stop_token ratio
+stop_token type_traits
 stop_token version
 streambuf algorithm
 streambuf atomic
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index b438907b35195..4d413f7331897 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -705,21 +705,65 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
+flat_map atomic
+flat_map cctype
+flat_map climits
 flat_map cmath
 flat_map compare
+flat_map concepts
 flat_map cstddef
 flat_map cstdint
+flat_map cstdio
+flat_map cstdlib
+flat_map cstring
+flat_map ctime
+flat_map cwchar
+flat_map cwctype
+flat_map exception
 flat_map initializer_list
+flat_map iosfwd
+flat_map iterator
 flat_map limits
+flat_map memory
+flat_map new
+flat_map optional
+flat_map ratio
+flat_map stdexcept
+flat_map tuple
 flat_map type_traits
+flat_map typeinfo
+flat_map utility
+flat_map variant
 flat_map version
+flat_set atomic
+flat_set cctype
+flat_set climits
 flat_set cmath
 flat_set compare
+flat_set concepts
 flat_set cstddef
 flat_set cstdint
+flat_set cstdio
+flat_set cstdlib
+flat_set cstring
+flat_set ctime
+flat_set cwchar
+flat_set cwctype
+flat_set exception
 flat_set initializer_list
+flat_set iosfwd
+flat_set iterator
 flat_set limits
+flat_set memory
+flat_set new
+flat_set optional
+flat_set ratio
+flat_set stdexcept
+flat_set tuple
 flat_set type_traits
+flat_set typeinfo
+flat_set utility
+flat_set variant
 flat_set version
 format algorithm
 format array
@@ -1739,7 +1783,9 @@ random utility
 random variant
 random vector
 random version
+ranges atomic
 ranges cctype
+ranges climits
 ranges cmath
 ranges compare
 ranges concepts
@@ -1748,6 +1794,7 @@ ranges cstdint
 ranges cstdio
 ranges cstdlib
 ranges cstring
+ranges ctime
 ranges cwchar
 ranges cwctype
 ranges exception
@@ -1755,7 +1802,11 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
+ranges memory
 ranges new
+ranges optional
+ranges ratio
+ranges stdexcept
 ranges tuple
 ranges type_traits
 ranges typeinfo
@@ -2106,8 +2157,19 @@ stdexcept new
 stdexcept type_traits
 stdexcept typeinfo
 stdexcept version
+stop_token atomic
+stop_token climits
+stop_token cmath
+stop_token compare
 stop_token cstddef
+stop_token cstdint
+stop_token cstdlib
+stop_token cstring
+stop_token ctime
 stop_token iosfwd
+stop_token limits
+stop_token ratio
+stop_token type_traits
 stop_token version
 streambuf algorithm
 streambuf atomic
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index a93fb1e26196b..4a986e95e282e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -714,21 +714,65 @@ filesystem utility
 filesystem variant
 filesystem vector
 filesystem version
+flat_map atomic
+flat_map cctype
+flat_map climits
 flat_map cmath
 flat_map compare
+flat_map concepts
 flat_map cstddef
 flat_map cstdint
+flat_map cstdio
+flat_map cstdlib
+flat_map cstring
+flat_map ctime
+flat_map cwchar
+flat_map cwctype
+flat_map exception
 flat_map initializer_list
+flat_map iosfwd
+flat_map iterator
 flat_map limits
+flat_map memory
+flat_map new
+flat_map optional
+flat_map ratio
+flat_map stdexcept
+flat_map tuple
 flat_map type_traits
+flat_map typeinfo
+flat_map utility
+flat_map variant
 flat_map version
+flat_set atomic
+flat_set cctype
+flat_set climits
 flat_set cmath
 flat_set compare
+flat_set concepts
 flat_set cstddef
 flat_set cstdint
+flat_set cstdio
+flat_set cstdlib
+flat_set cstring
+flat_set ctime
+flat_set cwchar
+flat_set cwctype
+flat_set exception
 flat_set initializer_list
+flat_set iosfwd
+flat_set iterator
 flat_set limits
+flat_set memory
+flat_set new
+flat_set optional
+flat_set ratio
+flat_set stdexcept
+flat_set tuple
 flat_set type_traits
+flat_set typeinfo
+flat_set utility
+flat_set variant
 flat_set version
 format algorithm
 format array
@@ -1759,7 +1803,9 @@ random utility
 random variant
 random vector
 random version
+ranges atomic
 ranges cctype
+ranges climits
 ranges cmath
 ranges compare
 ranges concepts
@@ -1768,6 +1814,7 @@ ranges cstdint
 ranges cstdio
 ranges cstdlib
 ranges cstring
+ranges ctime
 ranges cwchar
 ranges cwctype
 ranges exception
@@ -1775,7 +1822,11 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
+ranges memory
 ranges new
+ranges optional
+ranges ratio
+ranges stdexcept
 ranges tuple
 ranges type_traits
 ranges typeinfo
@@ -2120,8 +2171,19 @@ stdexcept new
 stdexcept type_traits
 stdexcept typeinfo
 stdexcept version
+stop_token atomic
+stop_token climits
+stop_token cmath
+stop_token compare
 stop_token cstddef
+stop_token cstdint
+stop_token cstdlib
+stop_token cstring
+stop_token ctime
 stop_token iosfwd
+stop_token limits
+stop_token ratio
+stop_token type_traits
 stop_token version
 streambuf algorithm
 streambuf atomic
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index ded0dd1a51c16..1b07db867bd15 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -705,21 +705,65 @@ filesystem utility
 filesystem variant
 filesystem vector
 filesystem version
+flat_map atomic
+flat_map cctype
+flat_map climits
 flat_map cmath
 flat_map compare
+flat_map concepts
 flat_map cstddef
 flat_map cstdint
+flat_map cstdio
+flat_map cstdlib
+flat_map cstring
+flat_map ctime
+flat_map cwchar
+flat_map cwctype
+flat_map exception
 flat_map initializer_list
+flat_map iosfwd
+flat_map iterator
 flat_map limits
+flat_map memory
+flat_map new
+flat_map optional
+flat_map ratio
+flat_map stdexcept
+flat_map tuple
 flat_map type_traits
+flat_map typeinfo
+flat_map utility
+flat_map variant
 flat_map version
+flat_set atomic
+flat_set cctype
+flat_set climits
 flat_set cmath
 flat_set compare
+flat_set concepts
 flat_set cstddef
 flat_set cstdint
+flat_set cstdio
+flat_set cstdlib
+flat_set cstring
+flat_set ctime
+flat_set cwchar
+flat_set cwctype
+flat_set exception
 flat_set initializer_list
+flat_set iosfwd
+flat_set iterator
 flat_set limits
+flat_set memory
+flat_set new
+flat_set optional
+flat_set ratio
+flat_set stdexcept
+flat_set tuple
 flat_set type_traits
+flat_set typeinfo
+flat_set utility
+flat_set variant
 flat_set version
 format algorithm
 format array
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index bb199e29a2a9d..2acd8ef28d907 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -9,6 +9,7 @@ algorithm cwctype
 algorithm initializer_list
 algorithm iosfwd
 algorithm limits
+algorithm optional
 algorithm ratio
 algorithm tuple
 algorithm version
@@ -122,6 +123,7 @@ chrono iosfwd
 chrono istream
 chrono limits
 chrono locale
+chrono optional
 chrono ratio
 chrono sstream
 chrono stdexcept
@@ -347,6 +349,7 @@ 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
@@ -359,6 +362,7 @@ 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
@@ -381,6 +385,7 @@ format initializer_list
 format ios
 format iosfwd
 format limits
+format optional
 format ratio
 format stdexcept
 format streambuf
@@ -439,6 +444,7 @@ functional cwchar
 functional cwctype
 functional initializer_list
 functional limits
+functional optional
 functional stdexcept
 functional tuple
 functional typeinfo
@@ -550,6 +556,7 @@ iostream iosfwd
 iostream istream
 iostream limits
 iostream locale
+iostream optional
 iostream ostream
 iostream print
 iostream ratio
@@ -654,6 +661,7 @@ map cwchar
 map cwctype
 map initializer_list
 map limits
+map optional
 map stdexcept
 map tuple
 map version
@@ -710,6 +718,7 @@ numeric cwchar
 numeric cwctype
 numeric initializer_list
 numeric limits
+numeric optional
 numeric ratio
 numeric tuple
 numeric version
@@ -741,6 +750,7 @@ ostream ios
 ostream iosfwd
 ostream limits
 ostream locale
+ostream optional
 ostream print
 ostream ratio
 ostream stdexcept
@@ -771,6 +781,7 @@ print initializer_list
 print ios
 print iosfwd
 print limits
+print optional
 print ratio
 print stdexcept
 print streambuf
@@ -818,6 +829,7 @@ random initializer_list
 random iosfwd
 random limits
 random numeric
+random optional
 random ratio
 random stdexcept
 random string
@@ -837,6 +849,7 @@ ranges initializer_list
 ranges iosfwd
 ranges iterator
 ranges limits
+ranges optional
 ranges span
 ranges stdexcept
 ranges tuple
@@ -890,6 +903,7 @@ set cwchar
 set cwctype
 set initializer_list
 set limits
+set optional
 set tuple
 set version
 shared_mutex cerrno
@@ -1059,6 +1073,7 @@ syncstream iosfwd
 syncstream limits
 syncstream locale
 syncstream map
+syncstream optional
 syncstream ostream
 syncstream print
 syncstream ratio
@@ -1138,6 +1153,7 @@ 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
@@ -1146,6 +1162,7 @@ unordered_set cstdint
 unordered_set cstring
 unordered_set initializer_list
 unordered_set limits
+unordered_set optional
 unordered_set tuple
 unordered_set version
 utility compare

>From e2653c51c646c7477f6b103a3321048ac3f92ebc Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sun, 2 Aug 2026 13:32:28 +0100
Subject: [PATCH 3/3] Reverted the formatting change

---
 libcxx/include/__format/format_functions.h | 55 +++++++++++-----------
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index 50a9ace7daf30..8dfa0786c82b1 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -407,10 +407,9 @@ 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));
@@ -432,22 +431,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
@@ -518,15 +517,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
@@ -573,8 +572,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
@@ -608,22 +607,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
@@ -651,15 +650,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
@@ -711,8 +710,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



More information about the libcxx-commits mailing list