[libcxx-commits] [libcxx] [libc++] Granularize <string_view> (PR #99683)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 19 11:37:28 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/99683

This reduces the time to include `<string>` from 267ms to 237ms.


>From fb2fbf70510f9420b53b72d6041e3a8a8c3e2dda Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 16 Apr 2024 20:17:25 +0200
Subject: [PATCH] [libc++] Granularize <string_view>

---
 libcxx/include/CMakeLists.txt                 |   2 +
 libcxx/include/__chrono/formatter.h           |   2 +-
 .../include/__chrono/parser_std_format_spec.h |   2 +-
 libcxx/include/__chrono/time_zone.h           |   2 +-
 libcxx/include/__chrono/time_zone_link.h      |   2 +-
 libcxx/include/__filesystem/path.h            |   2 +-
 libcxx/include/__filesystem/path_iterator.h   |   2 +-
 libcxx/include/__format/buffer.h              |   3 +-
 libcxx/include/__format/format_arg.h          |   3 +-
 libcxx/include/__format/format_arg_store.h    |   2 +-
 libcxx/include/__format/format_functions.h    |   3 +-
 .../include/__format/format_parse_context.h   |   3 +-
 libcxx/include/__format/formatter_integral.h  |   2 +-
 libcxx/include/__format/formatter_output.h    |   3 +-
 libcxx/include/__format/formatter_string.h    |   2 +-
 libcxx/include/__format/formatter_tuple.h     |   2 +-
 .../include/__format/parser_std_format_spec.h |   2 +-
 .../__format/range_default_formatter.h        |   3 +-
 libcxx/include/__format/range_formatter.h     |   2 +-
 libcxx/include/__format/unicode.h             |   4 +-
 libcxx/include/__format/write_escaped.h       |   5 +-
 libcxx/include/__ostream/basic_ostream.h      |   2 +-
 .../include/__string_view/basic_string_view.h | 697 +++++++++++++++++
 libcxx/include/__string_view/literals.h       |  58 ++
 libcxx/include/bitset                         |   3 +-
 libcxx/include/chrono                         |   2 +-
 libcxx/include/filesystem                     |   1 +
 libcxx/include/format                         |   1 +
 libcxx/include/module.modulemap               |   8 +-
 libcxx/include/ostream                        |   1 +
 libcxx/include/print                          |   2 +-
 libcxx/include/sstream                        |   3 +-
 libcxx/include/string                         |   3 +-
 libcxx/include/string_view                    | 719 +-----------------
 libcxx/include/thread                         |   1 +
 libcxx/include/vector                         |   1 +
 .../test/libcxx/transitive_includes/cxx03.csv |   5 +
 .../test/libcxx/transitive_includes/cxx11.csv |   7 +
 .../test/libcxx/transitive_includes/cxx14.csv |   7 +
 .../test/libcxx/transitive_includes/cxx17.csv |  11 +
 .../test/libcxx/transitive_includes/cxx20.csv |  11 +
 .../test/libcxx/transitive_includes/cxx23.csv |  36 +-
 .../test/libcxx/transitive_includes/cxx26.csv |  31 +-
 .../ostream.formatted.print/print_tests.h     |   2 +
 .../strings/string.view/char.bad.verify.cpp   |   6 +-
 .../comparison.verify.cpp                     |   8 +-
 46 files changed, 915 insertions(+), 764 deletions(-)
 create mode 100644 libcxx/include/__string_view/basic_string_view.h
 create mode 100644 libcxx/include/__string_view/literals.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index fa6736dc11e66..8e2ed7f82e322 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -687,6 +687,8 @@ set(files
   __string/char_traits.h
   __string/constexpr_c_functions.h
   __string/extern_template_lists.h
+  __string_view/basic_string_view.h
+  __string_view/literals.h
   __support/ibm/gettod_zos.h
   __support/ibm/locale_mgmt_zos.h
   __support/ibm/nanosleep.h
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 9a77316385abd..6ccd9cbddc110 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -44,11 +44,11 @@
 #include <__format/parser_std_format_spec.h>
 #include <__format/write_escaped.h>
 #include <__memory/addressof.h>
+#include <__string_view/basic_string_view.h>
 #include <cmath>
 #include <ctime>
 #include <limits>
 #include <sstream>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index 785bbae198e46..1ace0740f0e68 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -16,7 +16,7 @@
 #include <__format/format_parse_context.h>
 #include <__format/formatter_string.h>
 #include <__format/parser_std_format_spec.h>
-#include <string_view>
+#include <__string_view/basic_string_view.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__chrono/time_zone.h b/libcxx/include/__chrono/time_zone.h
index de11dac1eef0c..44910fd415707 100644
--- a/libcxx/include/__chrono/time_zone.h
+++ b/libcxx/include/__chrono/time_zone.h
@@ -25,8 +25,8 @@
 #  include <__compare/strong_order.h>
 #  include <__config>
 #  include <__memory/unique_ptr.h>
+#  include <__string_view/basic_string_view.h>
 #  include <__type_traits/common_type.h>
-#  include <string_view>
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    pragma GCC system_header
diff --git a/libcxx/include/__chrono/time_zone_link.h b/libcxx/include/__chrono/time_zone_link.h
index b2d365c5fd082..d49238360da55 100644
--- a/libcxx/include/__chrono/time_zone_link.h
+++ b/libcxx/include/__chrono/time_zone_link.h
@@ -18,9 +18,9 @@
 
 #  include <__compare/strong_order.h>
 #  include <__config>
+#  include <__string_view/basic_string_view.h>
 #  include <__utility/private_constructor_tag.h>
 #  include <string>
-#  include <string_view>
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    pragma GCC system_header
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index ff468d517722f..63f1783f608dc 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -17,13 +17,13 @@
 #include <__fwd/functional.h>
 #include <__iterator/back_insert_iterator.h>
 #include <__iterator/iterator_traits.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/decay.h>
 #include <__type_traits/is_pointer.h>
 #include <__type_traits/remove_const.h>
 #include <__type_traits/remove_pointer.h>
 #include <cstddef>
 #include <string>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #  include <iomanip> // for quoted
diff --git a/libcxx/include/__filesystem/path_iterator.h b/libcxx/include/__filesystem/path_iterator.h
index f4d486d86cf38..7feb11f346a7d 100644
--- a/libcxx/include/__filesystem/path_iterator.h
+++ b/libcxx/include/__filesystem/path_iterator.h
@@ -14,9 +14,9 @@
 #include <__config>
 #include <__filesystem/path.h>
 #include <__iterator/iterator_traits.h>
+#include <__string_view/basic_string_view.h>
 #include <cstddef>
 #include <string>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index 8598f0a1c0395..95159e4ecd3d2 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -17,6 +17,7 @@
 #include <__algorithm/ranges_copy_n.h>
 #include <__algorithm/transform.h>
 #include <__algorithm/unwrap_iter.h>
+#include <__assert>
 #include <__concepts/same_as.h>
 #include <__config>
 #include <__format/concepts.h>
@@ -33,12 +34,12 @@
 #include <__memory/construct_at.h>
 #include <__memory/ranges_construct_at.h>
 #include <__memory/uninitialized_algorithms.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/add_pointer.h>
 #include <__type_traits/conditional.h>
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
 #include <cstddef>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h
index aa02f81dc40e2..fa7ff20add9a0 100644
--- a/libcxx/include/__format/format_arg.h
+++ b/libcxx/include/__format/format_arg.h
@@ -18,14 +18,15 @@
 #include <__functional/invoke.h>
 #include <__fwd/format.h>
 #include <__memory/addressof.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/remove_const.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <__utility/unreachable.h>
 #include <__variant/monostate.h>
+#include <cstddef>
 #include <cstdint>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/format_arg_store.h b/libcxx/include/__format/format_arg_store.h
index 23a599e995759..0c64a6189fa67 100644
--- a/libcxx/include/__format/format_arg_store.h
+++ b/libcxx/include/__format/format_arg_store.h
@@ -19,11 +19,11 @@
 #include <__config>
 #include <__format/concepts.h>
 #include <__format/format_arg.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/extent.h>
 #include <__type_traits/remove_const.h>
 #include <string>
-#include <string_view>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index d14b49aff1495..f8d6c5e864fa3 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -35,10 +35,11 @@
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
 #include <__iterator/iterator_traits.h> // iter_value_t
+#include <__string_view/basic_string_view.h>
+#include <__type_traits/type_identity.h>
 #include <__variant/monostate.h>
 #include <array>
 #include <string>
-#include <string_view>
 
 #ifndef _LIBCPP_HAS_NO_LOCALIZATION
 #  include <__locale>
diff --git a/libcxx/include/__format/format_parse_context.h b/libcxx/include/__format/format_parse_context.h
index aefcd5497f3b9..772555b124e59 100644
--- a/libcxx/include/__format/format_parse_context.h
+++ b/libcxx/include/__format/format_parse_context.h
@@ -12,8 +12,9 @@
 
 #include <__config>
 #include <__format/format_error.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/is_constant_evaluated.h>
-#include <string_view>
+#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h
index eca966f8886f8..9ae29dbf651ba 100644
--- a/libcxx/include/__format/formatter_integral.h
+++ b/libcxx/include/__format/formatter_integral.h
@@ -23,13 +23,13 @@
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h>
 #include <__memory/pointer_traits.h>
+#include <__string_view/basic_string_view.h>
 #include <__system_error/errc.h>
 #include <__type_traits/make_unsigned.h>
 #include <__utility/unreachable.h>
 #include <array>
 #include <limits>
 #include <string>
-#include <string_view>
 
 #ifndef _LIBCPP_HAS_NO_LOCALIZATION
 #  include <__locale>
diff --git a/libcxx/include/__format/formatter_output.h b/libcxx/include/__format/formatter_output.h
index 1498f64c4aeff..6ef3ac1e24477 100644
--- a/libcxx/include/__format/formatter_output.h
+++ b/libcxx/include/__format/formatter_output.h
@@ -13,6 +13,7 @@
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_fill_n.h>
 #include <__algorithm/ranges_transform.h>
+#include <__assert>
 #include <__bit/countl.h>
 #include <__concepts/same_as.h>
 #include <__config>
@@ -26,10 +27,10 @@
 #include <__iterator/iterator_traits.h>
 #include <__memory/addressof.h>
 #include <__memory/pointer_traits.h>
+#include <__string_view/basic_string_view.h>
 #include <__utility/move.h>
 #include <__utility/unreachable.h>
 #include <cstddef>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/formatter_string.h b/libcxx/include/__format/formatter_string.h
index 347439fc8dff1..e7ef65fbcce57 100644
--- a/libcxx/include/__format/formatter_string.h
+++ b/libcxx/include/__format/formatter_string.h
@@ -17,8 +17,8 @@
 #include <__format/formatter_output.h>
 #include <__format/parser_std_format_spec.h>
 #include <__format/write_escaped.h>
+#include <__string_view/basic_string_view.h>
 #include <string>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/formatter_tuple.h b/libcxx/include/__format/formatter_tuple.h
index 030097a8797da..a9f5ebb17e5cb 100644
--- a/libcxx/include/__format/formatter_tuple.h
+++ b/libcxx/include/__format/formatter_tuple.h
@@ -21,10 +21,10 @@
 #include <__format/formatter.h>
 #include <__format/formatter_output.h>
 #include <__format/parser_std_format_spec.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/remove_cvref.h>
 #include <__utility/integer_sequence.h>
 #include <__utility/pair.h>
-#include <string_view>
 #include <tuple>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h
index 150bdde89f3b3..7a3a2be03eb9d 100644
--- a/libcxx/include/__format/parser_std_format_spec.h
+++ b/libcxx/include/__format/parser_std_format_spec.h
@@ -31,13 +31,13 @@
 #include <__iterator/concepts.h>
 #include <__iterator/iterator_traits.h> // iter_value_t
 #include <__memory/addressof.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/common_type.h>
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_trivially_copyable.h>
 #include <__variant/monostate.h>
 #include <cstdint>
 #include <string>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/range_default_formatter.h b/libcxx/include/__format/range_default_formatter.h
index b35223ae93329..f5f10759abb56 100644
--- a/libcxx/include/__format/range_default_formatter.h
+++ b/libcxx/include/__format/range_default_formatter.h
@@ -26,10 +26,11 @@
 #include <__ranges/data.h>
 #include <__ranges/from_range.h>
 #include <__ranges/size.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/remove_cvref.h>
 #include <__utility/pair.h>
-#include <string_view>
+#include <string>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
diff --git a/libcxx/include/__format/range_formatter.h b/libcxx/include/__format/range_formatter.h
index 6915630743493..2d77c8ff9f7fd 100644
--- a/libcxx/include/__format/range_formatter.h
+++ b/libcxx/include/__format/range_formatter.h
@@ -30,8 +30,8 @@
 #include <__ranges/data.h>
 #include <__ranges/from_range.h>
 #include <__ranges/size.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/remove_cvref.h>
-#include <string_view>
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
diff --git a/libcxx/include/__format/unicode.h b/libcxx/include/__format/unicode.h
index de7d0fea1df56..ba81955f31421 100644
--- a/libcxx/include/__format/unicode.h
+++ b/libcxx/include/__format/unicode.h
@@ -17,9 +17,9 @@
 #include <__format/extended_grapheme_cluster_table.h>
 #include <__format/indic_conjunct_break_table.h>
 #include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h>
+#include <__string_view/basic_string_view.h>
 #include <__utility/unreachable.h>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__format/write_escaped.h b/libcxx/include/__format/write_escaped.h
index 052ea98c3c3b8..a882bccf17a70 100644
--- a/libcxx/include/__format/write_escaped.h
+++ b/libcxx/include/__format/write_escaped.h
@@ -12,6 +12,7 @@
 
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_for_each.h>
+#include <__assert>
 #include <__charconv/to_chars_integral.h>
 #include <__charconv/to_chars_result.h>
 #include <__chrono/statically_widen.h>
@@ -20,11 +21,13 @@
 #include <__format/parser_std_format_spec.h>
 #include <__format/unicode.h>
 #include <__iterator/back_insert_iterator.h>
+#include <__iterator/concepts.h>
 #include <__memory/addressof.h>
+#include <__string_view/basic_string_view.h>
 #include <__system_error/errc.h>
 #include <__type_traits/make_unsigned.h>
 #include <__utility/move.h>
-#include <string_view>
+#include <string>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h
index 178359d681567..1c80f77b43005 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -11,6 +11,7 @@
 
 #include <__config>
 #include <__exception/operations.h>
+#include <__fwd/string_view.h>
 #include <__memory/shared_ptr.h>
 #include <__memory/unique_ptr.h>
 #include <__system_error/error_code.h>
@@ -25,7 +26,6 @@
 #include <locale>
 #include <new> // for __throw_bad_alloc
 #include <streambuf>
-#include <string_view>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__string_view/basic_string_view.h b/libcxx/include/__string_view/basic_string_view.h
new file mode 100644
index 0000000000000..7acb5950a9c87
--- /dev/null
+++ b/libcxx/include/__string_view/basic_string_view.h
@@ -0,0 +1,697 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___STRING_VIEW_BASIC_STRING_VIEW_H
+#define _LIBCPP___STRING_VIEW_BASIC_STRING_VIEW_H
+
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__compare/ordering.h>
+#include <__config>
+#include <__functional/hash.h>
+#include <__functional/unary_function.h>
+#include <__fwd/ostream.h>
+#include <__fwd/string_view.h>
+#include <__iterator/bounded_iter.h>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__iterator/wrap_iter.h>
+#include <__memory/pointer_traits.h>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/size.h>
+#include <__string/char_traits.h>
+#include <__type_traits/is_array.h>
+#include <__type_traits/is_convertible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_standard_layout.h>
+#include <__type_traits/is_trivial.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/type_identity.h>
+#include <cstddef>
+#include <limits>
+#include <stdexcept>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in
+//       string_view constructors. This can be refactored when this exact form isn't needed anymore.
+template <class _Traits>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR inline size_t
+__char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
+  // This needs to be a single statement for C++11 constexpr
+  return _LIBCPP_ASSERT_NON_NULL(
+             __s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"),
+         _Traits::length(__s);
+}
+
+template <class _CharT, class _Traits>
+class basic_string_view {
+public:
+  // types
+  using traits_type     = _Traits;
+  using value_type      = _CharT;
+  using pointer         = _CharT*;
+  using const_pointer   = const _CharT*;
+  using reference       = _CharT&;
+  using const_reference = const _CharT&;
+#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
+  using const_iterator = __bounded_iter<const_pointer>;
+#elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW)
+  using const_iterator = __wrap_iter<const_pointer>;
+#else
+  using const_iterator = const_pointer;
+#endif
+  using iterator                                = const_iterator;
+  using const_reverse_iterator                  = std::reverse_iterator<const_iterator>;
+  using reverse_iterator                        = const_reverse_iterator;
+  using size_type                               = size_t;
+  using difference_type                         = ptrdiff_t;
+  static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+
+  static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");
+  static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
+  static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");
+  static_assert(is_same<_CharT, typename traits_type::char_type>::value,
+                "traits_type::char_type must be the same type as CharT");
+
+  // [string.view.cons], construct/copy
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view() _NOEXCEPT : __data_(nullptr), __size_(0) {}
+
+  _LIBCPP_HIDE_FROM_ABI basic_string_view(const basic_string_view&) _NOEXCEPT = default;
+
+  _LIBCPP_HIDE_FROM_ABI basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
+      : __data_(__s),
+        __size_(__len) {
+#if _LIBCPP_STD_VER >= 14
+    // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input
+    // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently
+    // passed in a negative length.
+    _LIBCPP_ASSERT_VALID_INPUT_RANGE(
+        __len <= static_cast<size_type>(numeric_limits<difference_type>::max()),
+        "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");
+    _LIBCPP_ASSERT_NON_NULL(
+        __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
+#endif
+  }
+
+#if _LIBCPP_STD_VER >= 20
+  template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
+    requires(is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
+  constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
+      : __data_(std::to_address(__begin)), __size_(__end - __begin) {
+    _LIBCPP_ASSERT_VALID_INPUT_RANGE(
+        (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
+  }
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 23
+  template <class _Range>
+    requires(!is_same_v<remove_cvref_t<_Range>, basic_string_view> && ranges::contiguous_range<_Range> &&
+             ranges::sized_range<_Range> && is_same_v<ranges::range_value_t<_Range>, _CharT> &&
+             !is_convertible_v<_Range, const _CharT*> &&
+             (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); }))
+  constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r)
+      : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}
+#endif // _LIBCPP_STD_VER >= 23
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s)
+      : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {}
+
+#if _LIBCPP_STD_VER >= 23
+  basic_string_view(nullptr_t) = delete;
+#endif
+
+  // [string.view.iterators], iterators
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
+#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
+    return std::__make_bounded_iter(data(), data(), data() + size());
+#else
+    return const_iterator(__data_);
+#endif
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT {
+#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
+    return std::__make_bounded_iter(data() + size(), data(), data() + size());
+#else
+    return const_iterator(__data_ + __size_);
+#endif
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
+    return const_reverse_iterator(cend());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
+    return const_reverse_iterator(cbegin());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
+    return const_reverse_iterator(cend());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT {
+    return const_reverse_iterator(cbegin());
+  }
+
+  // [string.view.capacity], capacity
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type length() const _NOEXCEPT { return __size_; }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
+    return numeric_limits<size_type>::max() / sizeof(value_type);
+  }
+
+  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; }
+
+  // [string.view.access], element access
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT {
+    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos < size(), "string_view[] index out of bounds"), __data_[__pos];
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __pos) const {
+    return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data_[0]) : __data_[__pos];
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {
+    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::front(): string is empty"), __data_[0];
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {
+    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::back(): string is empty"), __data_[__size_ - 1];
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_pointer data() const _NOEXCEPT { return __data_; }
+
+  // [string.view.modifiers], modifiers:
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_prefix(size_type __n) _NOEXCEPT {
+    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n <= size(), "remove_prefix() can't remove more than size()");
+    __data_ += __n;
+    __size_ -= __n;
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_suffix(size_type __n) _NOEXCEPT {
+    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n <= size(), "remove_suffix() can't remove more than size()");
+    __size_ -= __n;
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void swap(basic_string_view& __other) _NOEXCEPT {
+    const value_type* __p = __data_;
+    __data_               = __other.__data_;
+    __other.__data_       = __p;
+
+    size_type __sz  = __size_;
+    __size_         = __other.__size_;
+    __other.__size_ = __sz;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
+  copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
+    if (__pos > size())
+      __throw_out_of_range("string_view::copy");
+    size_type __rlen = std::min(__n, size() - __pos);
+    _Traits::copy(__s, data() + __pos, __rlen);
+    return __rlen;
+  }
+
+  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const {
+    return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view())
+                          : basic_string_view(data() + __pos, std::min(__n, size() - __pos));
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT {
+    size_type __rlen = std::min(size(), __sv.size());
+    int __retval     = _Traits::compare(data(), __sv.data(), __rlen);
+    if (__retval == 0) // first __rlen chars matched
+      __retval = size() == __sv.size() ? 0 : (size() < __sv.size() ? -1 : 1);
+    return __retval;
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
+  compare(size_type __pos1, size_type __n1, basic_string_view __sv) const {
+    return substr(__pos1, __n1).compare(__sv);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
+  compare(size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const {
+    return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int compare(const _CharT* __s) const _NOEXCEPT {
+    return compare(basic_string_view(__s));
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
+  compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
+    return substr(__pos1, __n1).compare(basic_string_view(__s));
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
+  compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const {
+    return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
+  }
+
+  // find
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
+    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
+    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
+    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find(): received nullptr");
+    return std::__str_find<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+  // rfind
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
+    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
+    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
+    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  rfind(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::rfind(): received nullptr");
+    return std::__str_rfind<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+  // find_first_of
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
+    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
+    return find(__c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
+    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_of(): received nullptr");
+    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+  // find_last_of
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
+    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
+    return rfind(__c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
+    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_of(): received nullptr");
+    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+  // find_first_not_of
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_not_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(
+        __s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
+    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_not_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
+    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
+    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_first_not_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
+    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+  // find_last_not_of
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_not_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(
+        __s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
+    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s.data(), __pos, __s.size());
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_not_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
+    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
+    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
+  }
+
+  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
+  find_last_not_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
+    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
+    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
+        data(), size(), __s, __pos, traits_type::length(__s));
+  }
+
+#if _LIBCPP_STD_VER >= 20
+  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept {
+    return size() >= __s.size() && compare(0, __s.size(), __s) == 0;
+  }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept {
+    return !empty() && _Traits::eq(front(), __c);
+  }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept {
+    return starts_with(basic_string_view(__s));
+  }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(basic_string_view __s) const noexcept {
+    return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0;
+  }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept {
+    return !empty() && _Traits::eq(back(), __c);
+  }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {
+    return ends_with(basic_string_view(__s));
+  }
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; }
+
+  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; }
+#endif
+
+private:
+  const value_type* __data_;
+  size_type __size_;
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
+
+#if _LIBCPP_STD_VER >= 20
+template <class _CharT, class _Traits>
+inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
+
+template <class _CharT, class _Traits>
+inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
+#endif // _LIBCPP_STD_VER >= 20
+
+// [string.view.deduct]
+
+#if _LIBCPP_STD_VER >= 20
+template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
+basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 23
+template <ranges::contiguous_range _Range>
+basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
+#endif
+
+// [string.view.comparison]
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+                                                type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
+  if (__lhs.size() != __rhs.size())
+    return false;
+  return __lhs.compare(__rhs) == 0;
+}
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __lhs,
+                                                 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
+  if constexpr (requires { typename _Traits::comparison_category; }) {
+    // [string.view]/4
+    static_assert(
+        __comparison_category<typename _Traits::comparison_category>, "return type is not a comparison category type");
+    return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
+  } else {
+    return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
+  }
+}
+
+#else
+
+// operator ==
+
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return false;
+  return __lhs.compare(__rhs) == 0;
+}
+
+// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
+// This applies to the other sufficient overloads below for the other comparison operators.
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator==(basic_string_view<_CharT, _Traits> __lhs,
+           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return false;
+  return __lhs.compare(__rhs) == 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return false;
+  return __lhs.compare(__rhs) == 0;
+}
+
+// operator !=
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return true;
+  return __lhs.compare(__rhs) != 0;
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator!=(basic_string_view<_CharT, _Traits> __lhs,
+           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return true;
+  return __lhs.compare(__rhs) != 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  if (__lhs.size() != __rhs.size())
+    return true;
+  return __lhs.compare(__rhs) != 0;
+}
+
+// operator <
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) < 0;
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<(basic_string_view<_CharT, _Traits> __lhs,
+          __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) < 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+          basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) < 0;
+}
+
+// operator >
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) > 0;
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>(basic_string_view<_CharT, _Traits> __lhs,
+          __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) > 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+          basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) > 0;
+}
+
+// operator <=
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) <= 0;
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<=(basic_string_view<_CharT, _Traits> __lhs,
+           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) <= 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) <= 0;
+}
+
+// operator >=
+template <class _CharT, class _Traits>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) >= 0;
+}
+
+template <class _CharT, class _Traits, int = 1>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>=(basic_string_view<_CharT, _Traits> __lhs,
+           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) >= 0;
+}
+
+template <class _CharT, class _Traits, int = 2>
+_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
+           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
+  return __lhs.compare(__rhs) >= 0;
+}
+
+#endif //  _LIBCPP_STD_VER >= 20
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __str);
+
+// [string.view.hash]
+template <class _CharT>
+struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> {
+  _LIBCPP_HIDE_FROM_ABI size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
+    return std::__do_string_hash(__val.data(), __val.data() + __val.size());
+  }
+};
+
+template <>
+struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+template <>
+struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
+#endif
+
+template <>
+struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};
+
+template <>
+struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___STRING_VIEW_BASIC_STRING_VIEW_H
diff --git a/libcxx/include/__string_view/literals.h b/libcxx/include/__string_view/literals.h
new file mode 100644
index 0000000000000..e06b4f4c6770b
--- /dev/null
+++ b/libcxx/include/__string_view/literals.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___STRING_VIEW_LITERALS_H
+#define _LIBCPP___STRING_VIEW_LITERALS_H
+
+#include <__config>
+#include <__string_view/basic_string_view.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 14
+inline namespace literals {
+inline namespace string_view_literals {
+inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {
+  return basic_string_view<char>(__str, __len);
+}
+
+#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t>
+operator""sv(const wchar_t* __str, size_t __len) noexcept {
+  return basic_string_view<wchar_t>(__str, __len);
+}
+#  endif
+
+#  ifndef _LIBCPP_HAS_NO_CHAR8_T
+inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t>
+operator""sv(const char8_t* __str, size_t __len) noexcept {
+  return basic_string_view<char8_t>(__str, __len);
+}
+#  endif
+
+inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t>
+operator""sv(const char16_t* __str, size_t __len) noexcept {
+  return basic_string_view<char16_t>(__str, __len);
+}
+
+inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t>
+operator""sv(const char32_t* __str, size_t __len) noexcept {
+  return basic_string_view<char32_t>(__str, __len);
+}
+} // namespace string_view_literals
+} // namespace literals
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___STRING_VIEW_LITERALS_H
diff --git a/libcxx/include/bitset b/libcxx/include/bitset
index 6bd7bfe585f38..95ba8e67b9b96 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -133,11 +133,11 @@ template <size_t N> struct hash<std::bitset<N>>;
 #include <__config>
 #include <__functional/hash.h>
 #include <__functional/unary_function.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/is_char_like_type.h>
 #include <climits>
 #include <cstddef>
 #include <stdexcept>
-#include <string_view>
 #include <version>
 
 // standard-mandated includes
@@ -963,6 +963,7 @@ _LIBCPP_POP_MACROS
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <concepts>
 #  include <cstdlib>
+#  include <string_view>
 #  include <type_traits>
 #endif
 
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 7f25c76fda542..83c01bd11e0a0 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -991,7 +991,6 @@ constexpr chrono::year                                  operator ""y(unsigned lo
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
 #  include <cstdint>
 #  include <stdexcept>
-#  include <string_view>
 #  include <vector>
 #endif
 
@@ -1001,6 +1000,7 @@ constexpr chrono::year                                  operator ""y(unsigned lo
 #  include <cstring>
 #  include <forward_list>
 #  include <string>
+#  include <string_view>
 #  include <tuple>
 #endif
 
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 6ea04df0a089b..22a91df4bbda7 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -572,6 +572,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
 #  include <iosfwd>
 #  include <new>
 #  include <system_error>
+#  include <string_view>
 #endif
 
 #endif // _LIBCPP_FILESYSTEM
diff --git a/libcxx/include/format b/libcxx/include/format
index c3f2b45f0f730..cf5ae4f93fc96 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -252,6 +252,7 @@ namespace std {
 #  include <locale>
 #  include <queue>
 #  include <stack>
+#  include <string_view>
 #endif
 
 #endif // _LIBCPP_FORMAT
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 43ab9c6987c84..8e509d2f935fe 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1807,7 +1807,13 @@ module std_private_string_constexpr_c_functions [system] {
 module std_private_string_extern_template_lists [system] { header "__string/extern_template_lists.h" }
 module std_private_string_string_fwd            [system] { header "__fwd/string.h" }
 
-module std_private_string_view_string_view_fwd [system] { header "__fwd/string_view.h" }
+module std_private_string_view_basic_string_view [system] {
+  header "__string_view/basic_string_view.h"
+  export std_private_string_char_traits
+  export std_private_string_view_string_view_fwd
+}
+module std_private_string_view_literals          [system] { header "__string_view/literals.h" }
+module std_private_string_view_string_view_fwd   [system] { header "__fwd/string_view.h" }
 
 module std_private_system_error_errc            [system] { header "__system_error/errc.h" }
 module std_private_system_error_error_category  [system] { header "__system_error/error_category.h" }
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 359d3c0e19c4c..1a569fa86bdd7 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -196,6 +196,7 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
 #  include <iterator>
 #  include <print>
 #  include <stdexcept>
+#  include <string_view>
 #  include <type_traits>
 #endif
 
diff --git a/libcxx/include/print b/libcxx/include/print
index 1a579daff270f..471fa57a19ed1 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -36,13 +36,13 @@ namespace std {
 #include <__assert>
 #include <__concepts/same_as.h>
 #include <__config>
+#include <__string_view/basic_string_view.h>
 #include <__system_error/system_error.h>
 #include <__utility/forward.h>
 #include <cerrno>
 #include <cstdio>
 #include <format>
 #include <string>
-#include <string_view>
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 9ba43ffeb850f..e439118c4eb48 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -315,11 +315,11 @@ typedef basic_stringstream<wchar_t> wstringstream;
 #include <__config>
 #include <__fwd/sstream.h>
 #include <__ostream/basic_ostream.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/is_convertible.h>
 #include <__utility/swap.h>
 #include <istream>
 #include <string>
-#include <string_view>
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1270,6 +1270,7 @@ _LIBCPP_POP_MACROS
 
 #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
 #  include <ostream>
+#  include <string_view>
 #  include <type_traits>
 #endif
 
diff --git a/libcxx/include/string b/libcxx/include/string
index 54e9d8990c220..5cc70f21cdc2d 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -618,6 +618,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
 #include <__ranges/size.h>
 #include <__string/char_traits.h>
 #include <__string/extern_template_lists.h>
+#include <__string_view/basic_string_view.h>
 #include <__type_traits/conditional.h>
 #include <__type_traits/is_allocator.h>
 #include <__type_traits/is_array.h>
@@ -643,7 +644,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
 #include <cstring>
 #include <limits>
 #include <stdexcept>
-#include <string_view>
 #include <version>
 
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -4297,6 +4297,7 @@ _LIBCPP_POP_MACROS
 #  include <cstdlib>
 #  include <iterator>
 #  include <new>
+#  include <string_view>
 #  include <type_traits>
 #  include <typeinfo>
 #  include <utility>
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 72dbf0bfa8e54..802c8d01ea3a4 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -205,39 +205,15 @@ namespace std {
 
 // clang-format on
 
-#include <__algorithm/min.h>
-#include <__assert>
 #include <__config>
-#include <__functional/hash.h>
-#include <__functional/unary_function.h>
-#include <__fwd/ostream.h>
-#include <__fwd/string_view.h>
-#include <__iterator/bounded_iter.h>
-#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
-#include <__iterator/reverse_iterator.h>
-#include <__iterator/wrap_iter.h>
-#include <__memory/pointer_traits.h>
-#include <__ranges/concepts.h>
-#include <__ranges/data.h>
-#include <__ranges/enable_borrowed_range.h>
-#include <__ranges/enable_view.h>
-#include <__ranges/size.h>
-#include <__string/char_traits.h>
-#include <__type_traits/is_array.h>
-#include <__type_traits/is_convertible.h>
-#include <__type_traits/is_same.h>
-#include <__type_traits/is_standard_layout.h>
-#include <__type_traits/is_trivial.h>
-#include <__type_traits/remove_cvref.h>
-#include <__type_traits/remove_reference.h>
-#include <__type_traits/type_identity.h>
-#include <cstddef>
-#include <iosfwd>
-#include <limits>
-#include <stdexcept>
 #include <version>
 
+#include <__string_view/basic_string_view.h>
+
+#if _LIBCPP_STD_VER >= 14
+#  include <__string_view/literals.h>
+#endif
+
 // standard-mandated includes
 
 // [iterator.range]
@@ -254,689 +230,6 @@ namespace std {
 #  pragma GCC system_header
 #endif
 
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-// TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in
-//       string_view constructors. This can be refactored when this exact form isn't needed anymore.
-template <class _Traits>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR inline size_t
-__char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT {
-  // This needs to be a single statement for C++11 constexpr
-  return _LIBCPP_ASSERT_NON_NULL(
-             __s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"),
-         _Traits::length(__s);
-}
-
-template <class _CharT, class _Traits>
-class basic_string_view {
-public:
-  // types
-  using traits_type     = _Traits;
-  using value_type      = _CharT;
-  using pointer         = _CharT*;
-  using const_pointer   = const _CharT*;
-  using reference       = _CharT&;
-  using const_reference = const _CharT&;
-#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
-  using const_iterator = __bounded_iter<const_pointer>;
-#elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW)
-  using const_iterator = __wrap_iter<const_pointer>;
-#else
-  using const_iterator = const_pointer;
-#endif
-  using iterator                                = const_iterator;
-  using const_reverse_iterator                  = std::reverse_iterator<const_iterator>;
-  using reverse_iterator                        = const_reverse_iterator;
-  using size_type                               = size_t;
-  using difference_type                         = ptrdiff_t;
-  static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
-
-  static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");
-  static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
-  static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");
-  static_assert(is_same<_CharT, typename traits_type::char_type>::value,
-                "traits_type::char_type must be the same type as CharT");
-
-  // [string.view.cons], construct/copy
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view() _NOEXCEPT : __data_(nullptr), __size_(0) {}
-
-  _LIBCPP_HIDE_FROM_ABI basic_string_view(const basic_string_view&) _NOEXCEPT = default;
-
-  _LIBCPP_HIDE_FROM_ABI basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
-      : __data_(__s),
-        __size_(__len) {
-#if _LIBCPP_STD_VER >= 14
-    // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input
-    // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently
-    // passed in a negative length.
-    _LIBCPP_ASSERT_VALID_INPUT_RANGE(
-        __len <= static_cast<size_type>(numeric_limits<difference_type>::max()),
-        "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");
-    _LIBCPP_ASSERT_NON_NULL(
-        __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
-#endif
-  }
-
-#if _LIBCPP_STD_VER >= 20
-  template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
-    requires(is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
-  constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
-      : __data_(std::to_address(__begin)), __size_(__end - __begin) {
-    _LIBCPP_ASSERT_VALID_INPUT_RANGE(
-        (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
-  }
-#endif // _LIBCPP_STD_VER >= 20
-
-#if _LIBCPP_STD_VER >= 23
-  template <class _Range>
-    requires(!is_same_v<remove_cvref_t<_Range>, basic_string_view> && ranges::contiguous_range<_Range> &&
-             ranges::sized_range<_Range> && is_same_v<ranges::range_value_t<_Range>, _CharT> &&
-             !is_convertible_v<_Range, const _CharT*> &&
-             (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); }))
-  constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r)
-      : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}
-#endif // _LIBCPP_STD_VER >= 23
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s)
-      : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {}
-
-#if _LIBCPP_STD_VER >= 23
-  basic_string_view(nullptr_t) = delete;
-#endif
-
-  // [string.view.iterators], iterators
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
-    return std::__make_bounded_iter(data(), data(), data() + size());
-#else
-    return const_iterator(__data_);
-#endif
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT {
-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
-    return std::__make_bounded_iter(data() + size(), data(), data() + size());
-#else
-    return const_iterator(__data_ + __size_);
-#endif
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
-    return const_reverse_iterator(cend());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
-    return const_reverse_iterator(cbegin());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
-    return const_reverse_iterator(cend());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT {
-    return const_reverse_iterator(cbegin());
-  }
-
-  // [string.view.capacity], capacity
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type length() const _NOEXCEPT { return __size_; }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
-    return numeric_limits<size_type>::max() / sizeof(value_type);
-  }
-
-  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; }
-
-  // [string.view.access], element access
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT {
-    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos < size(), "string_view[] index out of bounds"), __data_[__pos];
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __pos) const {
-    return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data_[0]) : __data_[__pos];
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {
-    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::front(): string is empty"), __data_[0];
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {
-    return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::back(): string is empty"), __data_[__size_ - 1];
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_pointer data() const _NOEXCEPT { return __data_; }
-
-  // [string.view.modifiers], modifiers:
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_prefix(size_type __n) _NOEXCEPT {
-    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n <= size(), "remove_prefix() can't remove more than size()");
-    __data_ += __n;
-    __size_ -= __n;
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_suffix(size_type __n) _NOEXCEPT {
-    _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n <= size(), "remove_suffix() can't remove more than size()");
-    __size_ -= __n;
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void swap(basic_string_view& __other) _NOEXCEPT {
-    const value_type* __p = __data_;
-    __data_               = __other.__data_;
-    __other.__data_       = __p;
-
-    size_type __sz  = __size_;
-    __size_         = __other.__size_;
-    __other.__size_ = __sz;
-  }
-
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
-  copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
-    if (__pos > size())
-      __throw_out_of_range("string_view::copy");
-    size_type __rlen = std::min(__n, size() - __pos);
-    _Traits::copy(__s, data() + __pos, __rlen);
-    return __rlen;
-  }
-
-  _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const {
-    return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view())
-                          : basic_string_view(data() + __pos, std::min(__n, size() - __pos));
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT {
-    size_type __rlen = std::min(size(), __sv.size());
-    int __retval     = _Traits::compare(data(), __sv.data(), __rlen);
-    if (__retval == 0) // first __rlen chars matched
-      __retval = size() == __sv.size() ? 0 : (size() < __sv.size() ? -1 : 1);
-    return __retval;
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
-  compare(size_type __pos1, size_type __n1, basic_string_view __sv) const {
-    return substr(__pos1, __n1).compare(__sv);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
-  compare(size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const {
-    return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int compare(const _CharT* __s) const _NOEXCEPT {
-    return compare(basic_string_view(__s));
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
-  compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
-    return substr(__pos1, __n1).compare(basic_string_view(__s));
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int
-  compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const {
-    return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
-  }
-
-  // find
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
-    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
-    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
-    return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find(): received nullptr");
-    return std::__str_find<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-  // rfind
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
-    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
-    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
-    return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  rfind(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::rfind(): received nullptr");
-    return std::__str_rfind<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-  // find_first_of
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
-    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
-    return find(__c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
-    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_of(): received nullptr");
-    return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-  // find_last_of
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
-    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
-    return rfind(__c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
-    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_of(): received nullptr");
-    return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-  // find_first_not_of
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_not_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(
-        __s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
-    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_not_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT {
-    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
-    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_first_not_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
-    return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-  // find_last_not_of
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_not_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(
-        __s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
-    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s.data(), __pos, __s.size());
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_not_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT {
-    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
-    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
-  }
-
-  _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type
-  find_last_not_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT {
-    _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
-    return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
-        data(), size(), __s, __pos, traits_type::length(__s));
-  }
-
-#if _LIBCPP_STD_VER >= 20
-  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept {
-    return size() >= __s.size() && compare(0, __s.size(), __s) == 0;
-  }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept {
-    return !empty() && _Traits::eq(front(), __c);
-  }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept {
-    return starts_with(basic_string_view(__s));
-  }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(basic_string_view __s) const noexcept {
-    return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0;
-  }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept {
-    return !empty() && _Traits::eq(back(), __c);
-  }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {
-    return ends_with(basic_string_view(__s));
-  }
-#endif
-
-#if _LIBCPP_STD_VER >= 23
-  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; }
-
-  constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; }
-#endif
-
-private:
-  const value_type* __data_;
-  size_type __size_;
-};
-_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
-
-#if _LIBCPP_STD_VER >= 20
-template <class _CharT, class _Traits>
-inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
-
-template <class _CharT, class _Traits>
-inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
-#endif // _LIBCPP_STD_VER >= 20
-
-// [string.view.deduct]
-
-#if _LIBCPP_STD_VER >= 20
-template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
-basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
-#endif // _LIBCPP_STD_VER >= 20
-
-#if _LIBCPP_STD_VER >= 23
-template <ranges::contiguous_range _Range>
-basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
-#endif
-
-// [string.view.comparison]
-
-#if _LIBCPP_STD_VER >= 20
-
-template <class _CharT, class _Traits>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(basic_string_view<_CharT, _Traits> __lhs,
-                                                type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
-  if (__lhs.size() != __rhs.size())
-    return false;
-  return __lhs.compare(__rhs) == 0;
-}
-
-template <class _CharT, class _Traits>
-_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __lhs,
-                                                 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
-  if constexpr (requires { typename _Traits::comparison_category; }) {
-    // [string.view]/4
-    static_assert(
-        __comparison_category<typename _Traits::comparison_category>, "return type is not a comparison category type");
-    return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
-  } else {
-    return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
-  }
-}
-
-#else
-
-// operator ==
-
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return false;
-  return __lhs.compare(__rhs) == 0;
-}
-
-// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
-// This applies to the other sufficient overloads below for the other comparison operators.
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator==(basic_string_view<_CharT, _Traits> __lhs,
-           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return false;
-  return __lhs.compare(__rhs) == 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return false;
-  return __lhs.compare(__rhs) == 0;
-}
-
-// operator !=
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return true;
-  return __lhs.compare(__rhs) != 0;
-}
-
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator!=(basic_string_view<_CharT, _Traits> __lhs,
-           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return true;
-  return __lhs.compare(__rhs) != 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  if (__lhs.size() != __rhs.size())
-    return true;
-  return __lhs.compare(__rhs) != 0;
-}
-
-// operator <
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) < 0;
-}
-
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<(basic_string_view<_CharT, _Traits> __lhs,
-          __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) < 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-          basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) < 0;
-}
-
-// operator >
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) > 0;
-}
-
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>(basic_string_view<_CharT, _Traits> __lhs,
-          __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) > 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-          basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) > 0;
-}
-
-// operator <=
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) <= 0;
-}
-
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<=(basic_string_view<_CharT, _Traits> __lhs,
-           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) <= 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) <= 0;
-}
-
-// operator >=
-template <class _CharT, class _Traits>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) >= 0;
-}
-
-template <class _CharT, class _Traits, int = 1>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>=(basic_string_view<_CharT, _Traits> __lhs,
-           __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) >= 0;
-}
-
-template <class _CharT, class _Traits, int = 2>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
-operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
-           basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
-  return __lhs.compare(__rhs) >= 0;
-}
-
-#endif //  _LIBCPP_STD_VER >= 20
-
-template <class _CharT, class _Traits>
-_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
-operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __str);
-
-// [string.view.hash]
-template <class _CharT>
-struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> {
-  _LIBCPP_HIDE_FROM_ABI size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
-    return std::__do_string_hash(__val.data(), __val.data() + __val.size());
-  }
-};
-
-template <>
-struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
-
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
-template <>
-struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
-#endif
-
-template <>
-struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};
-
-template <>
-struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};
-
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template <>
-struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};
-#endif
-
-#if _LIBCPP_STD_VER >= 14
-inline namespace literals {
-inline namespace string_view_literals {
-inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {
-  return basic_string_view<char>(__str, __len);
-}
-
-#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t>
-operator""sv(const wchar_t* __str, size_t __len) noexcept {
-  return basic_string_view<wchar_t>(__str, __len);
-}
-#  endif
-
-#  ifndef _LIBCPP_HAS_NO_CHAR8_T
-inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t>
-operator""sv(const char8_t* __str, size_t __len) noexcept {
-  return basic_string_view<char8_t>(__str, __len);
-}
-#  endif
-
-inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t>
-operator""sv(const char16_t* __str, size_t __len) noexcept {
-  return basic_string_view<char16_t>(__str, __len);
-}
-
-inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t>
-operator""sv(const char32_t* __str, size_t __len) noexcept {
-  return basic_string_view<char32_t>(__str, __len);
-}
-} // namespace string_view_literals
-} // namespace literals
-#endif
-_LIBCPP_END_NAMESPACE_STD
-
-_LIBCPP_POP_MACROS
-
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <algorithm>
 #  include <concepts>
diff --git a/libcxx/include/thread b/libcxx/include/thread
index 25cb7ce6d7231..a3e7947aa2ea8 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -124,6 +124,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 #  include <functional>
 #  include <new>
 #  include <system_error>
+#  include <string_view>
 #  include <type_traits>
 #endif
 
diff --git a/libcxx/include/vector b/libcxx/include/vector
index aaf51d18fe30f..008fc6a49775d 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2983,6 +2983,7 @@ _LIBCPP_POP_MACROS
 #  if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #    include <locale>
 #  endif
+#  include <string_view>
 #  include <tuple>
 #  include <type_traits>
 #  include <typeinfo>
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 51e659f52000b..7ee544b63ccd5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -85,6 +85,7 @@ bitset climits
 bitset concepts
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstdlib
 bitset cstring
 bitset cwchar
@@ -268,10 +269,12 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format locale
 format new
@@ -604,6 +607,7 @@ ostream cstdint
 ostream cstdio
 ostream cstdlib
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
@@ -1004,6 +1008,7 @@ vector compare
 vector concepts
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 17e85e982729c..246b1e23ebe1b 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -85,6 +85,7 @@ bitset climits
 bitset concepts
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstdlib
 bitset cstring
 bitset cwchar
@@ -269,10 +270,12 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format locale
 format new
@@ -609,6 +612,7 @@ ostream cstdint
 ostream cstdio
 ostream cstdlib
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
@@ -889,11 +893,13 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
 thread cwchar
 thread functional
+thread initializer_list
 thread iosfwd
 thread limits
 thread locale
@@ -1011,6 +1017,7 @@ vector compare
 vector concepts
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 8aed93da9e6cc..0a8f1bf84fc4d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -86,6 +86,7 @@ bitset climits
 bitset concepts
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstdlib
 bitset cstring
 bitset cwchar
@@ -272,10 +273,12 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format locale
 format new
@@ -612,6 +615,7 @@ ostream cstdint
 ostream cstdio
 ostream cstdlib
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
@@ -892,11 +896,13 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
 thread cwchar
 thread functional
+thread initializer_list
 thread iosfwd
 thread limits
 thread locale
@@ -1014,6 +1020,7 @@ vector compare
 vector concepts
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 2c028462144ee..4abe66ec0be0b 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -86,6 +86,7 @@ bitset climits
 bitset concepts
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstdlib
 bitset cstring
 bitset cwchar
@@ -251,15 +252,19 @@ filesystem compare
 filesystem concepts
 filesystem cstddef
 filesystem cstdint
+filesystem cstdio
 filesystem cstdlib
 filesystem cstring
 filesystem ctime
+filesystem cwchar
+filesystem initializer_list
 filesystem iomanip
 filesystem iosfwd
 filesystem limits
 filesystem locale
 filesystem new
 filesystem ratio
+filesystem stdexcept
 filesystem string
 filesystem string_view
 filesystem system_error
@@ -272,10 +277,12 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format locale
 format new
@@ -613,6 +620,7 @@ ostream cstdint
 ostream cstdio
 ostream cstdlib
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
@@ -893,11 +901,13 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
 thread cwchar
 thread functional
+thread initializer_list
 thread iosfwd
 thread limits
 thread locale
@@ -1015,6 +1025,7 @@ vector compare
 vector concepts
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 982c2013e3417..eb1265e4c5ffc 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -85,6 +85,7 @@ bitset climits
 bitset concepts
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstdlib
 bitset cstring
 bitset cwchar
@@ -259,15 +260,19 @@ filesystem compare
 filesystem concepts
 filesystem cstddef
 filesystem cstdint
+filesystem cstdio
 filesystem cstdlib
 filesystem cstring
 filesystem ctime
+filesystem cwchar
+filesystem initializer_list
 filesystem iomanip
 filesystem iosfwd
 filesystem limits
 filesystem locale
 filesystem new
 filesystem ratio
+filesystem stdexcept
 filesystem string
 filesystem string_view
 filesystem system_error
@@ -280,10 +285,12 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format locale
 format new
@@ -620,6 +627,7 @@ ostream cstdint
 ostream cstdio
 ostream cstdlib
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
@@ -900,11 +908,13 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
 thread cwchar
 thread functional
+thread initializer_list
 thread iosfwd
 thread limits
 thread locale
@@ -1022,6 +1032,7 @@ vector compare
 vector concepts
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 8ffb71d8b566b..dd40aad80f47e 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -49,6 +49,7 @@ bit version
 bitset climits
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstring
 bitset cwchar
 bitset initializer_list
@@ -57,7 +58,6 @@ bitset limits
 bitset new
 bitset stdexcept
 bitset string
-bitset string_view
 bitset version
 ccomplex complex
 charconv cerrno
@@ -79,7 +79,12 @@ chrono ratio
 chrono sstream
 chrono stdexcept
 chrono string
+<<<<<<< HEAD
 chrono string_view
+=======
+chrono tuple
+chrono typeinfo
+>>>>>>> 304ff5003865 ([libc++] Granularize <string_view>)
 chrono vector
 chrono version
 cinttypes cstdint
@@ -169,13 +174,19 @@ experimental/utility utility
 filesystem compare
 filesystem cstddef
 filesystem cstdint
+filesystem cstdio
+filesystem cstring
 filesystem ctime
+filesystem cwchar
+filesystem initializer_list
 filesystem iomanip
+filesystem iosfwd
 filesystem limits
 filesystem locale
+filesystem new
 filesystem ratio
+filesystem stdexcept
 filesystem string
-filesystem string_view
 filesystem version
 format array
 format cctype
@@ -184,16 +195,17 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format new
 format optional
 format stdexcept
 format string
-format string_view
 format tuple
 format typeinfo
 format version
@@ -410,25 +422,33 @@ ostream cerrno
 ostream cstddef
 ostream cstdint
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
+ostream iosfwd
 ostream limits
 ostream locale
 ostream new
 ostream print
+ostream stdexcept
 ostream streambuf
 ostream string
-ostream string_view
 ostream typeinfo
 ostream version
 print cerrno
 print cstddef
+print cstdint
 print cstdio
+print cstring
+print cwchar
 print format
+print initializer_list
+print iosfwd
+print limits
+print new
 print stdexcept
 print string
-print string_view
 print version
 queue compare
 queue cstddef
@@ -580,7 +600,6 @@ string iosfwd
 string limits
 string new
 string stdexcept
-string string_view
 string tuple
 string version
 string_view compare
@@ -620,6 +639,7 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
@@ -633,7 +653,6 @@ thread ratio
 thread sstream
 thread stdexcept
 thread string
-thread string_view
 thread tuple
 thread typeinfo
 thread version
@@ -701,15 +720,16 @@ vector clocale
 vector compare
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
 vector initializer_list
+vector iosfwd
 vector limits
 vector new
 vector stdexcept
 vector string
-vector string_view
 vector tuple
 vector typeinfo
 vector version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 8ffb71d8b566b..3de7bd5ea3f6c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -49,6 +49,7 @@ bit version
 bitset climits
 bitset cstddef
 bitset cstdint
+bitset cstdio
 bitset cstring
 bitset cwchar
 bitset initializer_list
@@ -57,7 +58,6 @@ bitset limits
 bitset new
 bitset stdexcept
 bitset string
-bitset string_view
 bitset version
 ccomplex complex
 charconv cerrno
@@ -169,13 +169,19 @@ experimental/utility utility
 filesystem compare
 filesystem cstddef
 filesystem cstdint
+filesystem cstdio
+filesystem cstring
 filesystem ctime
+filesystem cwchar
+filesystem initializer_list
 filesystem iomanip
+filesystem iosfwd
 filesystem limits
 filesystem locale
+filesystem new
 filesystem ratio
+filesystem stdexcept
 filesystem string
-filesystem string_view
 filesystem version
 format array
 format cctype
@@ -184,16 +190,17 @@ format clocale
 format cmath
 format cstddef
 format cstdint
+format cstdio
 format cstdlib
 format cstring
 format cwchar
 format initializer_list
+format iosfwd
 format limits
 format new
 format optional
 format stdexcept
 format string
-format string_view
 format tuple
 format typeinfo
 format version
@@ -410,25 +417,33 @@ ostream cerrno
 ostream cstddef
 ostream cstdint
 ostream cstring
+ostream cwchar
 ostream format
 ostream initializer_list
 ostream ios
+ostream iosfwd
 ostream limits
 ostream locale
 ostream new
 ostream print
+ostream stdexcept
 ostream streambuf
 ostream string
-ostream string_view
 ostream typeinfo
 ostream version
 print cerrno
 print cstddef
+print cstdint
 print cstdio
+print cstring
+print cwchar
 print format
+print initializer_list
+print iosfwd
+print limits
+print new
 print stdexcept
 print string
-print string_view
 print version
 queue compare
 queue cstddef
@@ -580,7 +595,6 @@ string iosfwd
 string limits
 string new
 string stdexcept
-string string_view
 string tuple
 string version
 string_view compare
@@ -620,6 +634,7 @@ thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdio
 thread cstdlib
 thread cstring
 thread ctime
@@ -633,7 +648,6 @@ thread ratio
 thread sstream
 thread stdexcept
 thread string
-thread string_view
 thread tuple
 thread typeinfo
 thread version
@@ -701,15 +715,16 @@ vector clocale
 vector compare
 vector cstddef
 vector cstdint
+vector cstdio
 vector cstdlib
 vector cstring
 vector cwchar
 vector initializer_list
+vector iosfwd
 vector limits
 vector new
 vector stdexcept
 vector string
-vector string_view
 vector tuple
 vector typeinfo
 vector version
diff --git a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print_tests.h b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print_tests.h
index f5a6a639cbd30..14e3a4c60bc13 100644
--- a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print_tests.h
+++ b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print_tests.h
@@ -8,6 +8,8 @@
 #ifndef TEST_STD_INPUT_OUTPUT_IOSTREAM_FORMAT_OUTPUT_STREAMS_OSTREAM_FORMATTED_OSTREAM_FORMATTED_PRINT_PRINT_TESTS_H
 #define TEST_STD_INPUT_OUTPUT_IOSTREAM_FORMAT_OUTPUT_STREAMS_OSTREAM_FORMATTED_OSTREAM_FORMATTED_PRINT_PRINT_TESTS_H
 
+#include <string_view>
+
 template <class TestFunction, class ExceptionTest>
 void print_tests(TestFunction check, ExceptionTest check_exception) {
   // *** Test escaping  ***
diff --git a/libcxx/test/std/strings/string.view/char.bad.verify.cpp b/libcxx/test/std/strings/string.view/char.bad.verify.cpp
index 735e3e5d2e716..caa89435e07d9 100644
--- a/libcxx/test/std/strings/string.view/char.bad.verify.cpp
+++ b/libcxx/test/std/strings/string.view/char.bad.verify.cpp
@@ -35,21 +35,21 @@ int main(int, char**) {
     typedef char C[3];
     static_assert(std::is_array<C>::value, "");
     std::basic_string_view<C, test_traits<C> > sv;
-    //  expected-error-re at string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must not be an array}}
+    //  expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string_view must not be an array}}
   }
 
   {
     //  not trivial
     static_assert(!std::is_trivial<NotTrivial>::value, "");
     std::basic_string_view<NotTrivial, test_traits<NotTrivial> > sv;
-    //  expected-error-re at string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must be trivial}}
+    //  expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string_view must be trivial}}
   }
 
   {
     //  not standard layout
     static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
     std::basic_string_view<NotStandardLayout, test_traits<NotStandardLayout> > sv;
-    //  expected-error-re at string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must be standard-layout}}
+    //  expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string_view must be standard-layout}}
   }
 
   return 0;
diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/comparison.verify.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/comparison.verify.cpp
index 66626bc4243a3..f49ce5ba5fbb6 100644
--- a/libcxx/test/std/strings/string.view/string.view.comparison/comparison.verify.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.comparison/comparison.verify.cpp
@@ -62,14 +62,14 @@ void test() {
   // These diagnostics are issued for
   // - Every invalid ordering
   // - Every type
-  // expected-error-re at string_view:* 15 {{static assertion failed{{.*}}return type is not a comparison category type}}
+  // expected-error-re@*:* 15 {{static assertion failed{{.*}}return type is not a comparison category type}}
 
   // This diagnostic is not issued for Ordering == void.
-  // expected-error at string_view:* 10 {{no matching conversion for static_cast from}}
+  // expected-error@*:* 10 {{no matching conversion for static_cast from}}
 #else
   // One less test run when wchar_t is unavailable.
-  // expected-error-re at string_view:* 12 {{static assertion failed{{.*}}return type is not a comparison category type}}
-  // expected-error at string_view:* 8 {{no matching conversion for static_cast from}}
+  // expected-error-re@*:* 12 {{static assertion failed{{.*}}return type is not a comparison category type}}
+  // expected-error@*:* 8 {{no matching conversion for static_cast from}}
 #endif
     type{} <=> type{};
 }



More information about the libcxx-commits mailing list