[libcxx-commits] [libcxx] [libc++][sstream] P2495R3: Interfacing `stringstream`s with `string_view` (PR #80552)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 18 00:52:25 PST 2024


https://github.com/H-G-Hristov updated https://github.com/llvm/llvm-project/pull/80552

>From d34e182562f8fc49675f958069c473e1b672c7db Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Wed, 31 Jan 2024 12:26:19 +0200
Subject: [PATCH 01/17] [libc++][streams] P2495R3: Interfacing `stringstreams`
 with `string_view`

Implements P2495R3 <https://wg21.link/P2495R3>
- https://eel.is/c++draft/version.syn#headerref:%3csstream%3e
- https://eel.is/c++draft/stringbuf
  - https://eel.is/c++draft/stringbuf.general
  - https://eel.is/c++draft/stringbuf.cons
  - https://eel.is/c++draft/stringbuf.members
- https://eel.is/c++draft/istringstream
  - https://eel.is/c++draft/istringstream.general
  - https://eel.is/c++draft/istringstream.cons
  - https://eel.is/c++draft/istringstream.members
- https://eel.is/c++draft/ostringstream
  - https://eel.is/c++draft/ostringstream.general
  - https://eel.is/c++draft/ostringstream.cons
  - https://eel.is/c++draft/ostringstream.members
- https://eel.is/c++draft/stringstream
  - https://eel.is/c++draft/stringstream.general
  - https://eel.is/c++draft/stringstream.cons
  - https://eel.is/c++draft/stringstream.members

  References:
  - https://eel.is/c++draft/string.streams
---
 libcxx/docs/ReleaseNotes/19.rst               |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv            |   2 +-
 libcxx/include/sstream                        | 152 ++++++++++++++++++
 .../string_view.mode.alloc.pass.cpp           |  77 +++++++++
 .../str.string_view.pass.cpp                  | 105 ++++++++++++
 .../str.string_view.pass.cpp                  | 105 ++++++++++++
 .../str.string_view.pass.cpp                  | 105 ++++++++++++
 .../str.string_view.pass.cpp                  | 105 ++++++++++++
 .../generate_feature_test_macro_components.py |   1 -
 9 files changed, 651 insertions(+), 2 deletions(-)
 create mode 100644 libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp

diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 908d46b711a5a6..048c1e8f952aa0 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -40,6 +40,7 @@ Implemented Papers
 
 - P2637R3 - Member ``visit``
 - P2652R2 - Disallow User Specialization of ``allocator_traits``
+- P2495R3 - Interfacing ``stringstream``s with ``string_view``
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index a62faee4f44e22..dfc4208b5ccb50 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -6,7 +6,7 @@
 "`P2545R4 <https://wg21.link/P2545R4>`__","LWG","Read-Copy Update (RCU)","Varna June 2023","","",""
 "`P2530R3 <https://wg21.link/P2530R3>`__","LWG","Hazard Pointers for C++26","Varna June 2023","","",""
 "`P2538R1 <https://wg21.link/P2538R1>`__","LWG","ADL-proof ``std::projected``","Varna June 2023","|Complete|","18.0","|ranges|"
-"`P2495R3 <https://wg21.link/P2495R3>`__","LWG","Interfacing ``stringstreams`` with ``string_view``","Varna June 2023","","",""
+"`P2495R3 <https://wg21.link/P2495R3>`__","LWG","Interfacing ``stringstream``s with ``string_view``","Varna June 2023","|Complete|","19.0",""
 "`P2510R3 <https://wg21.link/P2510R3>`__","LWG","Formatting pointers","Varna June 2023","|Complete| [#note-P2510R3]_","17.0","|format|"
 "`P2198R7 <https://wg21.link/P2198R7>`__","LWG","Freestanding Feature-Test Macros and Implementation-Defined Extensions","Varna June 2023","","",""
 "`P2338R4 <https://wg21.link/P2338R4>`__","LWG","Freestanding Library: Character primitives and the C library","Varna June 2023","","",""
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 6c354cf0b39737..6f6da1cb9ba076 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -48,6 +48,13 @@ public:
     template <class SAlloc>
     explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
                              ios_base::openmode which = ios_base::in | ios_base::out); // C++20
+    template<class T>
+      explicit basic_stringbuf(const T& t,
+                               ios_base::openmode which = ios_base::in | ios_base::out); // Since C++26
+    template<class T>
+      basic_stringbuf(const T& t, const Allocator& a);                                   // Since C++26
+    template<class T>
+      basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);         // Since C++26
     basic_stringbuf(basic_stringbuf&& rhs);
     basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a);                   // C++20
 
@@ -67,6 +74,8 @@ public:
     template <class SAlloc>
     void str(const basic_string<char_type, traits_type, SAlloc>& s);                   // C++20
     void str(basic_string<char_type, traits_type, allocator_type>&& s);                // C++20
+    template<class T>
+      void str(const T& t);                                                            // Since C++26
 
 protected:
     // [stringbuf.virtuals] Overridden virtual functions:
@@ -119,6 +128,12 @@ public:
     template <class SAlloc>
     explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
                                  ios_base::openmode which = ios_base::in);             // C++20
+    template<class T>
+      explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in); // Since C++26
+    template<class T>
+      basic_istringstream(const T& t, const Allocator& a);                               // Since C++26
+    template<class T>
+      basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);     // Since C++26
     basic_istringstream(basic_istringstream&& rhs);
 
     // [istringstream.assign] Assign and swap:
@@ -137,6 +152,8 @@ public:
     template <class SAlloc>
     void str(const basic_string<char_type, traits_type, SAlloc>& s);                   // C++20
     void str(basic_string<char_type, traits_type, allocator_type>&& s);                // C++20
+    template<class T>
+      void str(const T& t);                                                            // Since C++26
 };
 
 template <class charT, class traits, class Allocator>
@@ -178,6 +195,12 @@ public:
     template <class SAlloc>
     explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
                                  ios_base::openmode which = ios_base::out);            // C++20
+    template<class T>
+      explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); // Since C++26
+    template<class T>
+      basic_ostringstream(const T& t, const Allocator& a);                                // Since C++26
+    template<class T>
+      basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);      // Since C++26
     basic_ostringstream(basic_ostringstream&& rhs);
 
     // [ostringstream.assign] Assign and swap:
@@ -196,6 +219,8 @@ public:
     template <class SAlloc>
     void str(const basic_string<char_type, traits_type, SAlloc>& s);                   // C++20
     void str(basic_string<char_type, traits_type, allocator_type>&& s);                // C++20
+    template<class T>
+      void str(const T& t);                                                            // Since C++26
 };
 
 template <class charT, class traits, class Allocator>
@@ -237,6 +262,13 @@ public:
     template <class SAlloc>
     explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
                                 ios_base::openmode which = ios_base::out | ios_base::in); // C++20
+    template<class T>
+      explicit basic_stringstream(const T& t,
+                                  ios_base::openmode which = ios_base::out | ios_base::in); // Since C++26
+    template<class T>
+      basic_stringstream(const T& t, const Allocator& a);                                   // Since C++26
+    template<class T>
+      basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a);         // Since C++26
     basic_stringstream(basic_stringstream&& rhs);
 
     // [stringstream.assign] Assign and swap:
@@ -255,6 +287,8 @@ public:
     template <class SAlloc>
     void str(const basic_string<char_type, traits_type, SAlloc>& s);                      // C++20
     void str(basic_string<char_type, traits_type, allocator_type>&& s);                   // C++20
+    template<class T>
+      void str(const T& t);                                                               // Since C++26
 };
 
 template <class charT, class traits, class Allocator>
@@ -274,10 +308,12 @@ typedef basic_stringstream<wchar_t> wstringstream;
 #include <__availability>
 #include <__config>
 #include <__fwd/sstream.h>
+#include <__type_traits/is_convertible.h>
 #include <__utility/swap.h>
 #include <istream>
 #include <ostream>
 #include <string>
+#include <string_view>
 #include <version>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -364,6 +400,30 @@ public:
   }
 #endif // _LIBCPP_STD_VER >= 20
 
+#if _LIBCPP_STD_VER >= 26
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const _Tp& __t,
+                                                 ios_base::openmode __which = ios_base::in | ios_base::out)
+      : basic_stringbuf(__t, __which, _Allocator()) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, const _Allocator& __a)
+      : basic_stringbuf(__t, ios_base::in | ios_base::out, __a) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+      : basic_stringbuf(__which, __a) {
+    basic_string_view<_CharT, _Traits> __sv = __t;
+    __str_                                  = __sv;
+    __init_buf_ptrs();
+  }
+
+#endif //  _LIBCPP_STD_VER >= 26
+
   basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
 
 #if _LIBCPP_STD_VER >= 20
@@ -435,6 +495,18 @@ public:
   }
 #endif // _LIBCPP_STD_VER >= 20
 
+#if _LIBCPP_STD_VER >= 26
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
+    basic_string_view<_CharT, _Traits> __sv = __t;
+    __str_                                  = __sv;
+    __init_buf_ptrs();
+  }
+
+#endif //  _LIBCPP_STD_VER >= 26
+
 protected:
   // [stringbuf.virtuals] Overridden virtual functions:
   int_type underflow() override;
@@ -822,6 +894,24 @@ public:
       : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
 #endif // _LIBCPP_STD_VER >= 20
 
+#if _LIBCPP_STD_VER >= 26
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
+      : basic_istringstream(__t, __which, _Allocator()) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_istringstream(const _Tp& __t, const _Allocator& __a) : basic_istringstream(__t, ios_base::in, __a) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+      : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
+
+#endif //  _LIBCPP_STD_VER >= 26
+
   _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
       : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
     basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
@@ -871,6 +961,14 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
 #endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
+    rdbuf()->str(__t);
+  }
+#endif //  _LIBCPP_STD_VER >= 26
 };
 
 template <class _CharT, class _Traits, class _Allocator>
@@ -929,6 +1027,24 @@ public:
       : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
 #endif // _LIBCPP_STD_VER >= 20
 
+#if _LIBCPP_STD_VER >= 26
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out)
+      : basic_ostringstream(__t, __which, _Allocator()) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_ostringstream(const _Tp& __t, const _Allocator& __a) : basic_ostringstream(__t, ios_base::out, __a) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+      : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
+
+#endif //  _LIBCPP_STD_VER >= 26
+
   _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
       : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
     basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
@@ -979,6 +1095,14 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
 #endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
+    rdbuf()->str(__t);
+  }
+#endif //  _LIBCPP_STD_VER >= 26
 };
 
 template <class _CharT, class _Traits, class _Allocator>
@@ -1040,6 +1164,26 @@ public:
       : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
 #endif // _LIBCPP_STD_VER >= 20
 
+#if _LIBCPP_STD_VER >= 26
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  explicit basic_stringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out | ios_base::in)
+      : basic_stringstream(__t, __which, _Allocator()) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_stringstream(const _Tp& __t, const _Allocator& __a)
+      : basic_stringstream(__t, ios_base::out | ios_base::in, __a) {}
+
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+      : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)),
+        __sb_(__t, __which | ios_base::out | ios_base::in, __a) {}
+
+#endif //  _LIBCPP_STD_VER >= 26
+
   _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
       : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
     basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
@@ -1089,6 +1233,14 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
 #endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+  template <class _Tp>
+    requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
+  _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
+    rdbuf()->str(__t);
+  }
+#endif //  _LIBCPP_STD_VER >= 26
 };
 
 template <class _CharT, class _Traits, class _Allocator>
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
new file mode 100644
index 00000000000000..659c89d2de5fb7
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+using namespace std::string_literals;
+using namespace std::string_view_literals;
+
+#define STR(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  // const ChartT*
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(STR("zmt"));
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        STR("zmt"), std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // basic_string_view<CharT>
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(SV("zmt"));
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        SV("zmt"), std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // basic_string<CharT>
+  {
+    const std::basic_string<CharT> s(STR("zmt"));
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s);
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_string<CharT> s(STR("zmt"));
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s, std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test<wchar_t>();
+#endif
+  return 0;
+}
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
new file mode 100644
index 00000000000000..1a1b63171d6c26
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_istringstream
+
+// template<class T>
+//   void str(const T& t);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include "test_macros.h"
+
+using namespace std::string_literals;
+using namespace std::string_view_literals;
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T sv) {
+  { s.str(sv) };
+};
+
+struct SomeObject {};
+
+// std::istringstream
+static_assert(HasStr<std::istringstream, std::string_view>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::istringstream, std::wstring_view>);
+#endif
+static_assert(HasStr<std::istringstream, const char*>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::istringstream, const wchar_t*>);
+#endif
+static_assert(HasStr<std::istringstream, std::string>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::istringstream, std::wstring>);
+#endif
+static_assert(!HasStr<std::istringstream, std::array<char, 0>>);
+static_assert(!HasStr<std::istringstream, char>);
+static_assert(!HasStr<std::istringstream, int>);
+static_assert(!HasStr<std::istringstream, SomeObject>);
+static_assert(!HasStr<std::istringstream, std::nullptr_t>);
+
+// std::wistringstream
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(HasStr<std::wistringstream, std::wstring_view>);
+static_assert(!HasStr<std::wistringstream, std::string_view>);
+static_assert(HasStr<std::wistringstream, const wchar_t*>);
+static_assert(!HasStr<std::wistringstream, const char*>);
+static_assert(HasStr<std::wistringstream, std::wstring>);
+static_assert(!HasStr<std::wistringstream, std::string>);
+static_assert(!HasStr<std::istringstream, std::array<wchar_t, 0>>);
+static_assert(!HasStr<std::wistringstream, wchar_t>);
+static_assert(!HasStr<std::wistringstream, int>);
+static_assert(!HasStr<std::wistringstream, SomeObject>);
+static_assert(!HasStr<std::wistringstream, std::nullptr_t>);
+#endif
+
+int main(int, char**) {
+  {
+    std::istringstream ss;
+    assert(ss.str().empty());
+    ss.str("ba");
+    assert(ss.str() == "ba");
+    ss.str("ma"sv);
+    assert(ss.str() == "ma");
+    ss.str("zmt"s);
+    assert(ss.str() == "zmt");
+    const std::string s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  {
+    std::wistringstream ss;
+    assert(ss.str().empty());
+    ss.str(L"ba");
+    assert(ss.str() == L"ba");
+    ss.str(L"ma"sv);
+    assert(ss.str() == L"ma");
+    ss.str(L"zmt"s);
+    assert(ss.str() == L"zmt");
+    const std::wstring s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+#endif
+
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
new file mode 100644
index 00000000000000..35a2e9754cc596
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_ostringstream
+
+// template<class T>
+//   void str(const T& t);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include "test_macros.h"
+
+using namespace std::string_literals;
+using namespace std::string_view_literals;
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T sv) {
+  { s.str(sv) };
+};
+
+struct SomeObject {};
+
+// std::ostringstream
+static_assert(HasStr<std::ostringstream, std::string_view>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::ostringstream, std::wstring_view>);
+#endif
+static_assert(HasStr<std::ostringstream, const char*>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::ostringstream, const wchar_t*>);
+#endif
+static_assert(HasStr<std::ostringstream, std::string>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::ostringstream, std::wstring>);
+#endif
+static_assert(!HasStr<std::ostringstream, std::array<char, 0>>);
+static_assert(!HasStr<std::ostringstream, char>);
+static_assert(!HasStr<std::ostringstream, int>);
+static_assert(!HasStr<std::ostringstream, SomeObject>);
+static_assert(!HasStr<std::ostringstream, std::nullptr_t>);
+
+// std::wostringstream
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(HasStr<std::wostringstream, std::wstring_view>);
+static_assert(!HasStr<std::wostringstream, std::string_view>);
+static_assert(HasStr<std::wostringstream, const wchar_t*>);
+static_assert(!HasStr<std::wostringstream, const char*>);
+static_assert(HasStr<std::wostringstream, std::wstring>);
+static_assert(!HasStr<std::wostringstream, std::string>);
+static_assert(!HasStr<std::ostringstream, std::array<wchar_t, 0>>);
+static_assert(!HasStr<std::wostringstream, wchar_t>);
+static_assert(!HasStr<std::wostringstream, int>);
+static_assert(!HasStr<std::wostringstream, SomeObject>);
+static_assert(!HasStr<std::wostringstream, std::nullptr_t>);
+#endif
+
+int main(int, char**) {
+  {
+    std::ostringstream ss;
+    assert(ss.str().empty());
+    ss.str("ba");
+    assert(ss.str() == "ba");
+    ss.str("ma"sv);
+    assert(ss.str() == "ma");
+    ss.str("zmt"s);
+    assert(ss.str() == "zmt");
+    const std::string s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  {
+    std::wostringstream ss;
+    assert(ss.str().empty());
+    ss.str(L"ba");
+    assert(ss.str() == L"ba");
+    ss.str(L"ma"sv);
+    assert(ss.str() == L"ma");
+    ss.str(L"zmt"s);
+    assert(ss.str() == L"zmt");
+    const std::wstring s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+#endif
+
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
new file mode 100644
index 00000000000000..e84fe8457bb85e
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringbuf
+
+// template<class T>
+//   void str(const T& t);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include "test_macros.h"
+
+using namespace std::string_literals;
+using namespace std::string_view_literals;
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T sv) {
+  { s.str(sv) };
+};
+
+struct SomeObject {};
+
+// std::stringbuf
+static_assert(HasStr<std::stringbuf, std::string_view>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringbuf, std::wstring_view>);
+#endif
+static_assert(HasStr<std::stringbuf, const char*>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringbuf, const wchar_t*>);
+#endif
+static_assert(HasStr<std::stringbuf, std::string>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringbuf, std::wstring>);
+#endif
+static_assert(!HasStr<std::stringbuf, std::array<char, 0>>);
+static_assert(!HasStr<std::stringbuf, char>);
+static_assert(!HasStr<std::stringbuf, int>);
+static_assert(!HasStr<std::stringbuf, SomeObject>);
+static_assert(!HasStr<std::stringbuf, std::nullptr_t>);
+
+// std::wstringbuf
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(HasStr<std::wstringbuf, std::wstring_view>);
+static_assert(!HasStr<std::wstringbuf, std::string_view>);
+static_assert(HasStr<std::wstringbuf, const wchar_t*>);
+static_assert(!HasStr<std::wstringbuf, const char*>);
+static_assert(HasStr<std::wstringbuf, std::wstring>);
+static_assert(!HasStr<std::wstringbuf, std::string>);
+static_assert(!HasStr<std::stringbuf, std::array<wchar_t, 0>>);
+static_assert(!HasStr<std::wstringbuf, wchar_t>);
+static_assert(!HasStr<std::wstringbuf, int>);
+static_assert(!HasStr<std::wstringbuf, SomeObject>);
+static_assert(!HasStr<std::wstringbuf, std::nullptr_t>);
+#endif
+
+int main(int, char**) {
+  {
+    std::stringbuf ss;
+    assert(ss.str().empty());
+    ss.str("ba");
+    assert(ss.str() == "ba");
+    ss.str("ma"sv);
+    assert(ss.str() == "ma");
+    ss.str("zmt"s);
+    assert(ss.str() == "zmt");
+    const std::string s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  {
+    std::wstringbuf ss;
+    assert(ss.str().empty());
+    ss.str(L"ba");
+    assert(ss.str() == L"ba");
+    ss.str(L"ma"sv);
+    assert(ss.str() == L"ma");
+    ss.str(L"zmt"s);
+    assert(ss.str() == L"zmt");
+    const std::wstring s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+#endif
+
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
new file mode 100644
index 00000000000000..63624929d09811
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   void str(const T& t);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include "test_macros.h"
+
+using namespace std::string_literals;
+using namespace std::string_view_literals;
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T sv) {
+  { s.str(sv) };
+};
+
+struct SomeObject {};
+
+// std::stringstream
+static_assert(HasStr<std::stringstream, std::string_view>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringstream, std::wstring_view>);
+#endif
+static_assert(HasStr<std::stringstream, const char*>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringstream, const wchar_t*>);
+#endif
+static_assert(HasStr<std::stringstream, std::string>);
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!HasStr<std::stringstream, std::wstring>);
+#endif
+static_assert(!HasStr<std::stringstream, std::array<char, 0>>);
+static_assert(!HasStr<std::stringstream, char>);
+static_assert(!HasStr<std::stringstream, int>);
+static_assert(!HasStr<std::stringstream, SomeObject>);
+static_assert(!HasStr<std::stringstream, std::nullptr_t>);
+
+// std::wstringstream
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(HasStr<std::wstringstream, std::wstring_view>);
+static_assert(!HasStr<std::wstringstream, std::string_view>);
+static_assert(HasStr<std::wstringstream, const wchar_t*>);
+static_assert(!HasStr<std::wstringstream, const char*>);
+static_assert(HasStr<std::wstringstream, std::wstring>);
+static_assert(!HasStr<std::wstringstream, std::string>);
+static_assert(!HasStr<std::stringstream, std::array<wchar_t, 0>>);
+static_assert(!HasStr<std::wstringstream, wchar_t>);
+static_assert(!HasStr<std::wstringstream, int>);
+static_assert(!HasStr<std::wstringstream, SomeObject>);
+static_assert(!HasStr<std::wstringstream, std::nullptr_t>);
+#endif
+
+int main(int, char**) {
+  {
+    std::stringstream ss;
+    assert(ss.str().empty());
+    ss.str("ba");
+    assert(ss.str() == "ba");
+    ss.str("ma"sv);
+    assert(ss.str() == "ma");
+    ss.str("zmt"s);
+    assert(ss.str() == "zmt");
+    const std::string s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  {
+    std::wstringstream ss;
+    assert(ss.str().empty());
+    ss.str(L"ba");
+    assert(ss.str() == L"ba");
+    ss.str(L"ma"sv);
+    assert(ss.str() == L"ma");
+    ss.str(L"zmt"s);
+    assert(ss.str() == L"zmt");
+    const std::wstring s;
+    ss.str(s);
+    assert(ss.str().empty());
+  }
+#endif
+
+  return 0;
+}
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 6078e811c8e1ee..dd08880c045916 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1108,7 +1108,6 @@ def add_version_header(tc):
                 "c++26": 202306  # P2495R3 Interfacing stringstreams with string_view
             },
             "headers": ["sstream"],
-            "unimplemented": True,
         },
         {
             "name": "__cpp_lib_stacktrace",

>From 38a5cf2d7a457dcd2410c37f5aded7e4babd9289 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 08:46:30 +0200
Subject: [PATCH 02/17] Refactored: `str`, ctrs

---
 .../string_view.alloc.pass.cpp                | 106 +++++++++++
 .../string_view.mode.alloc.pass.cpp           | 169 +++++++++++++++---
 .../string_view.mode.pass.cpp                 | 102 +++++++++++
 .../str.string_view.pass.cpp                  |  99 ++++------
 .../string_view.mode.alloc.pass.cpp           | 132 ++++++++++++++
 .../str.string_view.pass.cpp                  |  99 ++++------
 .../str.string_view.pass.cpp                  | 100 ++++-------
 .../str.string_view.pass.cpp                  |  99 ++++------
 8 files changed, 617 insertions(+), 289 deletions(-)
 create mode 100644 libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
new file mode 100644
index 00000000000000..2eb19ab6089813
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_istringstream(const T& t, const Allocator& a);
+
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+struct SomeObject {};
+struct NonAllocator {};
+
+template <typename CharT>
+void test_constraints() {
+  // `const CharT*`
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string<CharT>,
+                                 test_allocator<CharT>>());
+
+  // Non-convertible to std::`basic_string_view<CharT>`
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  int,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int&,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  SomeObject,
+
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject&,
+                                  test_allocator<CharT>>());
+
+  // Allocator
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  std::basic_string<CharT>,
+                                  NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_constraints<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 659c89d2de5fb7..fc42fc5a8a413a 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -21,57 +21,170 @@
 #include <sstream>
 #include <string>
 #include <string_view>
-#include <type_traits>
 
 #include "make_string.h"
 #include "test_allocator.h"
+#include "test_convertible.h"
 #include "test_macros.h"
 
-using namespace std::string_literals;
-using namespace std::string_view_literals;
+template <typename S, typename T, typename A>
+concept HasMember = requires(const T& sv, std::ios_base::openmode w, const A& a) {
+  { S(sv, w, a) };
+};
 
-#define STR(S) MAKE_STRING(CharT, S)
+template <typename CharT>
+void test_constraints() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                          const CharT*,
+                          test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                          std::basic_string_view<CharT>,
+                          test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                          std::basic_string<CharT>,
+                          std::ios_base::openmode,
+                          test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string<CharT>,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+
+  // Non-convertible to std::`basic_string_view<CharT>`
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  int,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int&,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  SomeObject,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject&,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+
+  // Mode
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  std::basic_string<CharT>,
+                                  SomeObject,
+                                  NonAllocator>());
+
+  // Allocator
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  std::basic_string<CharT>,
+                                  std::ios_base::openmode,
+                                  NonAllocator>());
+}
+
+// #include <concepts>
+// #include <type_traits>
+
+// static_assert(std::is_constructible_v<std::istringstream, std::string_view>);
+// static_assert(test_convertible<std::basic_istringstream<char, std::char_traits<char>>,
+//                                const char*,
+//                                std::ios_base::openmode>());
+// static_assert(std::is_constructible_v<std::istringstream, int, test_allocator<int>>);
+
+// static_assert(HasMember<std::istringstream, std::string_view, test_allocator<char>>);
+
+//  std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>
+// static_assert(HasMember<std::basic_istringstream<char, std::char_traits<char>, test_allocator<char>>,
+//                         const char*,
+//                         test_allocator<char>>);
+
+// // std::istringstream
+// static_assert(HasMember<std::istringstream, std::string_view>);
+// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
+// static_assert(!HasMember<std::istringstream, std::wstring_view>);
+// #  endif
+// static_assert(HasMember<std::istringstream, const char*>);
+// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
+// static_assert(!HasMember<std::istringstream, const wchar_t*>);
+// #  endif
+// static_assert(HasMember<std::istringstream, std::string>);
+// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
+// static_assert(!HasMember<std::istringstream, std::wstring>);
+// #  endif
+// static_assert(!HasMember<std::istringstream, std::array<char, 1>>);
+// static_assert(!HasMember<std::istringstream, std::array<char, 0>>);
+// // static_assert(!HasMember<std::istringstream, char>);
+// // static_assert(!HasMember<std::istringstream, int>);
+// static_assert(!HasMember<std::istringstream, SomeObject>);
+// static_assert(!HasMember<std::istringstream, std::nullptr_t>);
+
+// // std::wistringstream
+
+// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
+// static_assert(HasMember<std::wistringstream, std::wstring_view>);
+// static_assert(!HasMember<std::wistringstream, std::string_view>);
+// static_assert(HasMember<std::wistringstream, const wchar_t*>);
+// static_assert(!HasMember<std::wistringstream, const char*>);
+// static_assert(HasMember<std::wistringstream, std::wstring>);
+// static_assert(!HasMember<std::wistringstream, std::string>);
+// static_assert(!HasMember<std::istringstream, std::array<wchar_t, 0>>);
+// // static_assert(!HasMember<std::wistringstream, wchar_t>);
+// // static_assert(!HasMember<std::wistringstream, int>);
+// static_assert(!HasMember<std::wistringstream, SomeObject>);
+// static_assert(!HasMember<std::wistringstream, std::nullptr_t>);
+// #  endif
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
 #define SV(S) MAKE_STRING_VIEW(CharT, S)
 
 template <class CharT>
 static void test() {
-  // const ChartT*
-  {
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(STR("zmt"));
-    assert(ss.view() == SV("zmt"));
-  }
+  const test_allocator<CharT> ca;
+
+  // const CharT*
   {
     const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        STR("zmt"), std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
-  }
-  // basic_string_view<CharT>
-  {
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(SV("zmt"));
-    assert(ss.view() == SV("zmt"));
+        CS("zmt"), std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
+  // std::basic_string_view<CharT>
   {
+    const auto csv = SV("zmt");
     const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        SV("zmt"), std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
-  }
-  // basic_string<CharT>
-  {
-    const std::basic_string<CharT> s(STR("zmt"));
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s);
-    assert(ss.view() == SV("zmt"));
+        csv, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
+  // std::basic_string<CharT>
   {
-    const std::basic_string<CharT> s(STR("zmt"));
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s, std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    const auto cs = ST("zmt");
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        cs, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
 }
 
 int main(int, char**) {
+  test_constraints<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_constraints<wchar_t>();
   test<wchar_t>();
 #endif
   return 0;
-}
\ No newline at end of file
+}
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
new file mode 100644
index 00000000000000..86f41cc3b62db8
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_istringstream(const T& t, ios_base::openmode which);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+struct SomeObject {};
+
+template <typename CharT>
+void test_constraints() {
+  // `const CharT*`
+  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+  //                                const CharT*,
+  //                                std::ios_base::openmode>());
+  // `std::basic_string_view<CharT>`
+  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+  //                                std::basic_string_view<CharT, std::char_traits<CharT>>,
+  //                                std::ios_base::openmode>());
+  // // `std::basic_string<CharT>`
+  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                std::basic_string<CharT>,
+  //                                std::ios_base::openmode>());
+
+  // // Non-convertible to std::`basic_string_view<CharT>`
+  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                 int,
+  //                                 std::ios_base::openmode>());
+  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                 const int&,
+  //                                 std::ios_base::openmode>());
+  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                 SomeObject,
+  //                                 std::ios_base::openmode>());
+  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                 const SomeObject&,
+  //                                 std::ios_base::openmode>());
+
+  // // Mode
+  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  //                                 std::basic_string<CharT>,
+  //                                 SomeObject>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  // const CharT*
+  {
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        csv, std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_constraints<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
index 1a1b63171d6c26..501f76d00acfee 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -16,89 +16,58 @@
 // template<class T>
 //   void str(const T& t);
 
-#include <array>
 #include <cassert>
 #include <sstream>
 #include <string>
 #include <string_view>
-#include <type_traits>
 
+#include "make_string.h"
 #include "test_macros.h"
 
-using namespace std::string_literals;
-using namespace std::string_view_literals;
-
 template <typename S, typename T>
-concept HasStr = requires(S s, const T sv) {
+concept HasMember = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
 struct SomeObject {};
 
-// std::istringstream
-static_assert(HasStr<std::istringstream, std::string_view>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::istringstream, std::wstring_view>);
-#endif
-static_assert(HasStr<std::istringstream, const char*>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::istringstream, const wchar_t*>);
-#endif
-static_assert(HasStr<std::istringstream, std::string>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::istringstream, std::wstring>);
-#endif
-static_assert(!HasStr<std::istringstream, std::array<char, 0>>);
-static_assert(!HasStr<std::istringstream, char>);
-static_assert(!HasStr<std::istringstream, int>);
-static_assert(!HasStr<std::istringstream, SomeObject>);
-static_assert(!HasStr<std::istringstream, std::nullptr_t>);
+template <typename CharT>
+void test_constraints() {
+  static_assert(HasMember<std::basic_istringstream<CharT>, const CharT*>);
+  static_assert(HasMember<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasMember<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
 
-// std::wistringstream
+  static_assert(!HasMember<std::basic_istringstream<CharT>, char>);
+  static_assert(!HasMember<std::basic_istringstream<CharT>, int>);
+  static_assert(!HasMember<std::basic_istringstream<CharT>, SomeObject>);
+  static_assert(!HasMember<std::basic_istringstream<CharT>, std::nullptr_t>);
+}
 
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(HasStr<std::wistringstream, std::wstring_view>);
-static_assert(!HasStr<std::wistringstream, std::string_view>);
-static_assert(HasStr<std::wistringstream, const wchar_t*>);
-static_assert(!HasStr<std::wistringstream, const char*>);
-static_assert(HasStr<std::wistringstream, std::wstring>);
-static_assert(!HasStr<std::wistringstream, std::string>);
-static_assert(!HasStr<std::istringstream, std::array<wchar_t, 0>>);
-static_assert(!HasStr<std::wistringstream, wchar_t>);
-static_assert(!HasStr<std::wistringstream, int>);
-static_assert(!HasStr<std::wistringstream, SomeObject>);
-static_assert(!HasStr<std::wistringstream, std::nullptr_t>);
-#endif
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
 
-int main(int, char**) {
-  {
-    std::istringstream ss;
-    assert(ss.str().empty());
-    ss.str("ba");
-    assert(ss.str() == "ba");
-    ss.str("ma"sv);
-    assert(ss.str() == "ma");
-    ss.str("zmt"s);
-    assert(ss.str() == "zmt");
-    const std::string s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+template <typename CharT>
+void test() {
+  std::basic_istringstream<CharT> ss;
+  assert(ss.str().empty());
+  ss.str(CS("ba"));
+  assert(ss.str() == CS("ba"));
+  ss.str(SV("ma"));
+  assert(ss.str() == CS("ma"));
+  ss.str(ST("zmt"));
+  assert(ss.str() == CS("zmt"));
+  const std::basic_string<CharT> s;
+  ss.str(s);
+  assert(ss.str().empty());
+}
 
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  {
-    std::wistringstream ss;
-    assert(ss.str().empty());
-    ss.str(L"ba");
-    assert(ss.str() == L"ba");
-    ss.str(L"ma"sv);
-    assert(ss.str() == L"ma");
-    ss.str(L"zmt"s);
-    assert(ss.str() == L"zmt");
-    const std::wstring s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+  test_constraints<wchar_t>();
+  test<wchar_t>();
 #endif
 
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp
new file mode 100644
index 00000000000000..59659505055f5f
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);
+
+#include <array>
+#include <cassert>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+struct SomeObject {};
+struct NonAllocator {};
+
+template <typename CharT>
+void test_constraints() {
+  // `const CharT*`
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string<CharT>,
+                                 std::ios_base::openmode,
+                                 test_allocator<CharT>>());
+
+  // Non-convertible to std::`basic_string_view<CharT>`
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  int,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int&,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  SomeObject,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject&,
+                                  std::ios_base::openmode,
+                                  test_allocator<CharT>>());
+
+  // Mode
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  std::basic_string<CharT>,
+                                  SomeObject,
+                                  NonAllocator>());
+
+  // Allocator
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  std::basic_string<CharT>,
+                                  std::ios_base::openmode,
+                                  NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  using namespace std::string_literals;
+  using namespace std::string_view_literals;
+
+  // const CharT*
+  {
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"));
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // std::basic_string_view<CharT>
+  {
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(SV("zmt"));
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        SV("zmt"), std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+  // std::basic_string<CharT>
+  {
+    const std::basic_string<CharT> s(ST("zmt"));
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s);
+    assert(ss.view() == SV("zmt"));
+  }
+  {
+    const std::basic_string<CharT> s(ST("zmt"));
+    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s, std::ios_base::binary);
+    assert(ss.view() == SV("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_constraints<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
index 35a2e9754cc596..018be464f61d3c 100644
--- a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
@@ -16,89 +16,58 @@
 // template<class T>
 //   void str(const T& t);
 
-#include <array>
 #include <cassert>
 #include <sstream>
 #include <string>
 #include <string_view>
-#include <type_traits>
 
+#include "make_string.h"
 #include "test_macros.h"
 
-using namespace std::string_literals;
-using namespace std::string_view_literals;
-
 template <typename S, typename T>
-concept HasStr = requires(S s, const T sv) {
+concept HasMember = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
 struct SomeObject {};
 
-// std::ostringstream
-static_assert(HasStr<std::ostringstream, std::string_view>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::ostringstream, std::wstring_view>);
-#endif
-static_assert(HasStr<std::ostringstream, const char*>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::ostringstream, const wchar_t*>);
-#endif
-static_assert(HasStr<std::ostringstream, std::string>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::ostringstream, std::wstring>);
-#endif
-static_assert(!HasStr<std::ostringstream, std::array<char, 0>>);
-static_assert(!HasStr<std::ostringstream, char>);
-static_assert(!HasStr<std::ostringstream, int>);
-static_assert(!HasStr<std::ostringstream, SomeObject>);
-static_assert(!HasStr<std::ostringstream, std::nullptr_t>);
+template <typename CharT>
+void test_constraints() {
+  static_assert(HasMember<std::basic_ostringstream<CharT>, const CharT*>);
+  static_assert(HasMember<std::basic_ostringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasMember<std::basic_ostringstream<CharT>, std::basic_string<CharT>>);
 
-// std::wostringstream
+  static_assert(!HasMember<std::basic_ostringstream<CharT>, char>);
+  static_assert(!HasMember<std::basic_ostringstream<CharT>, int>);
+  static_assert(!HasMember<std::basic_ostringstream<CharT>, SomeObject>);
+  static_assert(!HasMember<std::basic_ostringstream<CharT>, std::nullptr_t>);
+}
 
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(HasStr<std::wostringstream, std::wstring_view>);
-static_assert(!HasStr<std::wostringstream, std::string_view>);
-static_assert(HasStr<std::wostringstream, const wchar_t*>);
-static_assert(!HasStr<std::wostringstream, const char*>);
-static_assert(HasStr<std::wostringstream, std::wstring>);
-static_assert(!HasStr<std::wostringstream, std::string>);
-static_assert(!HasStr<std::ostringstream, std::array<wchar_t, 0>>);
-static_assert(!HasStr<std::wostringstream, wchar_t>);
-static_assert(!HasStr<std::wostringstream, int>);
-static_assert(!HasStr<std::wostringstream, SomeObject>);
-static_assert(!HasStr<std::wostringstream, std::nullptr_t>);
-#endif
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
 
-int main(int, char**) {
-  {
-    std::ostringstream ss;
-    assert(ss.str().empty());
-    ss.str("ba");
-    assert(ss.str() == "ba");
-    ss.str("ma"sv);
-    assert(ss.str() == "ma");
-    ss.str("zmt"s);
-    assert(ss.str() == "zmt");
-    const std::string s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+template <typename CharT>
+void test() {
+  std::basic_ostringstream<CharT> ss;
+  assert(ss.str().empty());
+  ss.str(CS("ba"));
+  assert(ss.str() == CS("ba"));
+  ss.str(SV("ma"));
+  assert(ss.str() == CS("ma"));
+  ss.str(ST("zmt"));
+  assert(ss.str() == CS("zmt"));
+  const std::basic_string<CharT> s;
+  ss.str(s);
+  assert(ss.str().empty());
+}
 
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  {
-    std::wostringstream ss;
-    assert(ss.str().empty());
-    ss.str(L"ba");
-    assert(ss.str() == L"ba");
-    ss.str(L"ma"sv);
-    assert(ss.str() == L"ma");
-    ss.str(L"zmt"s);
-    assert(ss.str() == L"zmt");
-    const std::wstring s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+  test_constraints<wchar_t>();
+  test<wchar_t>();
 #endif
 
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
index e84fe8457bb85e..f0fbc7d273f950 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
@@ -15,90 +15,58 @@
 
 // template<class T>
 //   void str(const T& t);
-
-#include <array>
 #include <cassert>
 #include <sstream>
 #include <string>
 #include <string_view>
-#include <type_traits>
 
+#include "make_string.h"
 #include "test_macros.h"
 
-using namespace std::string_literals;
-using namespace std::string_view_literals;
-
 template <typename S, typename T>
-concept HasStr = requires(S s, const T sv) {
+concept HasMember = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
 struct SomeObject {};
 
-// std::stringbuf
-static_assert(HasStr<std::stringbuf, std::string_view>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringbuf, std::wstring_view>);
-#endif
-static_assert(HasStr<std::stringbuf, const char*>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringbuf, const wchar_t*>);
-#endif
-static_assert(HasStr<std::stringbuf, std::string>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringbuf, std::wstring>);
-#endif
-static_assert(!HasStr<std::stringbuf, std::array<char, 0>>);
-static_assert(!HasStr<std::stringbuf, char>);
-static_assert(!HasStr<std::stringbuf, int>);
-static_assert(!HasStr<std::stringbuf, SomeObject>);
-static_assert(!HasStr<std::stringbuf, std::nullptr_t>);
+template <typename CharT>
+void test_constraints() {
+  static_assert(HasMember<std::basic_stringbuf<CharT>, const CharT*>);
+  static_assert(HasMember<std::basic_stringbuf<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasMember<std::basic_stringbuf<CharT>, std::basic_string<CharT>>);
 
-// std::wstringbuf
+  static_assert(!HasMember<std::basic_stringbuf<CharT>, char>);
+  static_assert(!HasMember<std::basic_stringbuf<CharT>, int>);
+  static_assert(!HasMember<std::basic_stringbuf<CharT>, SomeObject>);
+  static_assert(!HasMember<std::basic_stringbuf<CharT>, std::nullptr_t>);
+}
 
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(HasStr<std::wstringbuf, std::wstring_view>);
-static_assert(!HasStr<std::wstringbuf, std::string_view>);
-static_assert(HasStr<std::wstringbuf, const wchar_t*>);
-static_assert(!HasStr<std::wstringbuf, const char*>);
-static_assert(HasStr<std::wstringbuf, std::wstring>);
-static_assert(!HasStr<std::wstringbuf, std::string>);
-static_assert(!HasStr<std::stringbuf, std::array<wchar_t, 0>>);
-static_assert(!HasStr<std::wstringbuf, wchar_t>);
-static_assert(!HasStr<std::wstringbuf, int>);
-static_assert(!HasStr<std::wstringbuf, SomeObject>);
-static_assert(!HasStr<std::wstringbuf, std::nullptr_t>);
-#endif
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
 
-int main(int, char**) {
-  {
-    std::stringbuf ss;
-    assert(ss.str().empty());
-    ss.str("ba");
-    assert(ss.str() == "ba");
-    ss.str("ma"sv);
-    assert(ss.str() == "ma");
-    ss.str("zmt"s);
-    assert(ss.str() == "zmt");
-    const std::string s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+template <typename CharT>
+void test() {
+  std::basic_stringbuf<CharT> ss;
+  assert(ss.str().empty());
+  ss.str(CS("ba"));
+  assert(ss.str() == CS("ba"));
+  ss.str(SV("ma"));
+  assert(ss.str() == CS("ma"));
+  ss.str(ST("zmt"));
+  assert(ss.str() == CS("zmt"));
+  const std::basic_string<CharT> s;
+  ss.str(s);
+  assert(ss.str().empty());
+}
 
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  {
-    std::wstringbuf ss;
-    assert(ss.str().empty());
-    ss.str(L"ba");
-    assert(ss.str() == L"ba");
-    ss.str(L"ma"sv);
-    assert(ss.str() == L"ma");
-    ss.str(L"zmt"s);
-    assert(ss.str() == L"zmt");
-    const std::wstring s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+  test_constraints<wchar_t>();
+  test<wchar_t>();
 #endif
 
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
index 63624929d09811..76c2963580911b 100644
--- a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
@@ -16,89 +16,58 @@
 // template<class T>
 //   void str(const T& t);
 
-#include <array>
 #include <cassert>
 #include <sstream>
 #include <string>
 #include <string_view>
-#include <type_traits>
 
+#include "make_string.h"
 #include "test_macros.h"
 
-using namespace std::string_literals;
-using namespace std::string_view_literals;
-
 template <typename S, typename T>
-concept HasStr = requires(S s, const T sv) {
+concept HasMember = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
 struct SomeObject {};
 
-// std::stringstream
-static_assert(HasStr<std::stringstream, std::string_view>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringstream, std::wstring_view>);
-#endif
-static_assert(HasStr<std::stringstream, const char*>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringstream, const wchar_t*>);
-#endif
-static_assert(HasStr<std::stringstream, std::string>);
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(!HasStr<std::stringstream, std::wstring>);
-#endif
-static_assert(!HasStr<std::stringstream, std::array<char, 0>>);
-static_assert(!HasStr<std::stringstream, char>);
-static_assert(!HasStr<std::stringstream, int>);
-static_assert(!HasStr<std::stringstream, SomeObject>);
-static_assert(!HasStr<std::stringstream, std::nullptr_t>);
+template <typename CharT>
+void test_constraints() {
+  static_assert(HasMember<std::basic_stringstream<CharT>, const CharT*>);
+  static_assert(HasMember<std::basic_stringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasMember<std::basic_stringstream<CharT>, std::basic_string<CharT>>);
 
-// std::wstringstream
+  static_assert(!HasMember<std::basic_stringstream<CharT>, char>);
+  static_assert(!HasMember<std::basic_stringstream<CharT>, int>);
+  static_assert(!HasMember<std::basic_stringstream<CharT>, SomeObject>);
+  static_assert(!HasMember<std::basic_stringstream<CharT>, std::nullptr_t>);
+}
 
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(HasStr<std::wstringstream, std::wstring_view>);
-static_assert(!HasStr<std::wstringstream, std::string_view>);
-static_assert(HasStr<std::wstringstream, const wchar_t*>);
-static_assert(!HasStr<std::wstringstream, const char*>);
-static_assert(HasStr<std::wstringstream, std::wstring>);
-static_assert(!HasStr<std::wstringstream, std::string>);
-static_assert(!HasStr<std::stringstream, std::array<wchar_t, 0>>);
-static_assert(!HasStr<std::wstringstream, wchar_t>);
-static_assert(!HasStr<std::wstringstream, int>);
-static_assert(!HasStr<std::wstringstream, SomeObject>);
-static_assert(!HasStr<std::wstringstream, std::nullptr_t>);
-#endif
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
 
-int main(int, char**) {
-  {
-    std::stringstream ss;
-    assert(ss.str().empty());
-    ss.str("ba");
-    assert(ss.str() == "ba");
-    ss.str("ma"sv);
-    assert(ss.str() == "ma");
-    ss.str("zmt"s);
-    assert(ss.str() == "zmt");
-    const std::string s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+template <typename CharT>
+void test() {
+  std::basic_stringstream<CharT> ss;
+  assert(ss.str().empty());
+  ss.str(CS("ba"));
+  assert(ss.str() == CS("ba"));
+  ss.str(SV("ma"));
+  assert(ss.str() == CS("ma"));
+  ss.str(ST("zmt"));
+  assert(ss.str() == CS("zmt"));
+  const std::basic_string<CharT> s;
+  ss.str(s);
+  assert(ss.str().empty());
+}
 
+int main(int, char**) {
+  test_constraints<char>();
+  test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  {
-    std::wstringstream ss;
-    assert(ss.str().empty());
-    ss.str(L"ba");
-    assert(ss.str() == L"ba");
-    ss.str(L"ma"sv);
-    assert(ss.str() == L"ma");
-    ss.str(L"zmt"s);
-    assert(ss.str() == L"zmt");
-    const std::wstring s;
-    ss.str(s);
-    assert(ss.str().empty());
-  }
+  test_constraints<wchar_t>();
+  test<wchar_t>();
 #endif
 
   return 0;

>From 5948644a0fff821df70d5af01a14e1a6b2176b1b Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 12:31:16 +0200
Subject: [PATCH 03/17] Added all tests

---
 .../string_view.alloc.pass.cpp                |  62 +++----
 .../string_view.mode.alloc.pass.cpp           | 153 +++++++-----------
 .../string_view.mode.pass.cpp                 |  94 ++++++-----
 .../str.string_view.pass.cpp                  |  26 +--
 .../string_view.alloc.pass.cpp                | 114 +++++++++++++
 .../string_view.mode.alloc.pass.cpp           | 119 ++++++++------
 .../string_view.mode.pass.cpp                 | 116 +++++++++++++
 .../str.string_view.pass.cpp                  |  26 +--
 .../stringbuf.cons/string_view.alloc.pass.cpp | 112 +++++++++++++
 .../string_view.mode.alloc.pass.cpp           | 141 ++++++++++++++++
 .../stringbuf.cons/string_view.mode.pass.cpp  | 111 +++++++++++++
 .../str.string_view.pass.cpp                  |  26 +--
 .../string_view.alloc.pass.cpp                | 112 +++++++++++++
 .../string_view.mode.alloc.pass.cpp           | 141 ++++++++++++++++
 .../string_view.mode.pass.cpp                 | 112 +++++++++++++
 .../str.string_view.pass.cpp                  |  26 +--
 16 files changed, 1220 insertions(+), 271 deletions(-)
 create mode 100644 libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
 create mode 100644 libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
index 2eb19ab6089813..92ec33f6a0d61b 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
@@ -17,6 +17,7 @@
 //   basic_istringstream(const T& t, const Allocator& a);
 
 #include <cassert>
+#include <concepts>
 #include <sstream>
 #include <string>
 #include <string_view>
@@ -26,43 +27,50 @@
 #include "test_convertible.h"
 #include "test_macros.h"
 
-struct SomeObject {};
-struct NonAllocator {};
-
 template <typename CharT>
-void test_constraints() {
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
   // `const CharT*`
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
                                  const CharT*,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
   // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string_view<CharT>,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
                                  std::basic_string_view<CharT>,
                                  test_allocator<CharT>>());
   // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string<CharT>,
-                                 test_allocator<CharT>>());
-
-  // Non-convertible to std::`basic_string_view<CharT>`
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  int,
-                                  test_allocator<CharT>>());
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const int&,
-                                  test_allocator<CharT>>());
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  SomeObject,
+                                 const std::basic_string<CharT>,
+                                 const test_allocator<CharT>>());
 
-                                  test_allocator<CharT>>());
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               const test_allocator<CharT>>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject&,
-                                  test_allocator<CharT>>());
+                                  const SomeObject,
+                                  const test_allocator<CharT>>());
 
   // Allocator
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               const NonAllocator>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  std::basic_string<CharT>,
-                                  NonAllocator>());
+                                  const std::basic_string_view<CharT>,
+                                  const NonAllocator>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -75,31 +83,31 @@ static void test() {
 
   // const CharT*
   {
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index fc42fc5a8a413a..a8c4b80cb032bb 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -16,8 +16,8 @@
 // template<class T>
 //   basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
 
-#include <array>
 #include <cassert>
+#include <concepts>
 #include <sstream>
 #include <string>
 #include <string_view>
@@ -27,125 +27,82 @@
 #include "test_convertible.h"
 #include "test_macros.h"
 
-template <typename S, typename T, typename A>
-concept HasMember = requires(const T& sv, std::ios_base::openmode w, const A& a) {
-  { S(sv, w, a) };
-};
-
 template <typename CharT>
-void test_constraints() {
+void test_sfinae() {
   struct SomeObject {};
   struct NonAllocator {};
 
   // `const CharT*`
-  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                          const CharT*,
-                          test_allocator<CharT>>);
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
                                  const CharT*,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
   // `std::basic_string_view<CharT>`
-  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                          std::basic_string_view<CharT>,
-                          test_allocator<CharT>>);
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        std::basic_string_view<CharT>,
+                                        std::ios_base::openmode,
+                                        test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string_view<CharT>,
+                                 const std::basic_string_view<CharT>,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
   // `std::basic_string<CharT>`
-  static_assert(HasMember<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                          std::basic_string<CharT>,
-                          std::ios_base::openmode,
-                          test_allocator<CharT>>);
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string<CharT>,
+                                 const std::basic_string<CharT>,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
-
-  // Non-convertible to std::`basic_string_view<CharT>`
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const int,
+                               std::ios_base::openmode,
+                               const test_allocator<CharT>>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  int,
+                                  const int,
                                   std::ios_base::openmode,
-                                  test_allocator<CharT>>());
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const int&,
-                                  std::ios_base::openmode,
-                                  test_allocator<CharT>>());
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  SomeObject,
-                                  std::ios_base::openmode,
-                                  test_allocator<CharT>>());
+                                  const test_allocator<CharT>>());
+
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               std::ios_base::openmode,
+                               const test_allocator<CharT>>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject&,
+                                  const SomeObject,
                                   std::ios_base::openmode,
-                                  test_allocator<CharT>>());
+                                  const test_allocator<CharT>>());
 
   // Mode
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               SomeObject,
+                               const NonAllocator>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  std::basic_string<CharT>,
+                                  const std::basic_string_view<CharT>,
                                   SomeObject,
-                                  NonAllocator>());
+                                  const NonAllocator>());
 
   // Allocator
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               std::ios_base::openmode,
+                               const NonAllocator>);
   static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  std::basic_string<CharT>,
+                                  const std::basic_string_view<CharT>,
                                   std::ios_base::openmode,
-                                  NonAllocator>());
+                                  const NonAllocator>());
 }
 
-// #include <concepts>
-// #include <type_traits>
-
-// static_assert(std::is_constructible_v<std::istringstream, std::string_view>);
-// static_assert(test_convertible<std::basic_istringstream<char, std::char_traits<char>>,
-//                                const char*,
-//                                std::ios_base::openmode>());
-// static_assert(std::is_constructible_v<std::istringstream, int, test_allocator<int>>);
-
-// static_assert(HasMember<std::istringstream, std::string_view, test_allocator<char>>);
-
-//  std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>
-// static_assert(HasMember<std::basic_istringstream<char, std::char_traits<char>, test_allocator<char>>,
-//                         const char*,
-//                         test_allocator<char>>);
-
-// // std::istringstream
-// static_assert(HasMember<std::istringstream, std::string_view>);
-// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
-// static_assert(!HasMember<std::istringstream, std::wstring_view>);
-// #  endif
-// static_assert(HasMember<std::istringstream, const char*>);
-// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
-// static_assert(!HasMember<std::istringstream, const wchar_t*>);
-// #  endif
-// static_assert(HasMember<std::istringstream, std::string>);
-// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
-// static_assert(!HasMember<std::istringstream, std::wstring>);
-// #  endif
-// static_assert(!HasMember<std::istringstream, std::array<char, 1>>);
-// static_assert(!HasMember<std::istringstream, std::array<char, 0>>);
-// // static_assert(!HasMember<std::istringstream, char>);
-// // static_assert(!HasMember<std::istringstream, int>);
-// static_assert(!HasMember<std::istringstream, SomeObject>);
-// static_assert(!HasMember<std::istringstream, std::nullptr_t>);
-
-// // std::wistringstream
-
-// #  ifndef TEST_HAS_NO_WIDE_CHARACTERS
-// static_assert(HasMember<std::wistringstream, std::wstring_view>);
-// static_assert(!HasMember<std::wistringstream, std::string_view>);
-// static_assert(HasMember<std::wistringstream, const wchar_t*>);
-// static_assert(!HasMember<std::wistringstream, const char*>);
-// static_assert(HasMember<std::wistringstream, std::wstring>);
-// static_assert(!HasMember<std::wistringstream, std::string>);
-// static_assert(!HasMember<std::istringstream, std::array<wchar_t, 0>>);
-// // static_assert(!HasMember<std::wistringstream, wchar_t>);
-// // static_assert(!HasMember<std::wistringstream, int>);
-// static_assert(!HasMember<std::wistringstream, SomeObject>);
-// static_assert(!HasMember<std::wistringstream, std::nullptr_t>);
-// #  endif
-
 #define CS(S) MAKE_CSTRING(CharT, S)
 #define ST(S) MAKE_STRING(CharT, S)
 #define SV(S) MAKE_STRING_VIEW(CharT, S)
@@ -156,7 +113,7 @@ static void test() {
 
   // const CharT*
   {
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
         CS("zmt"), std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
@@ -164,26 +121,24 @@ static void test() {
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        csv, std::ios_base::binary, ca);
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        cs, std::ios_base::binary, ca);
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
index 86f41cc3b62db8..46e4d864cc1220 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
@@ -16,8 +16,8 @@
 // template<class T>
 //   basic_istringstream(const T& t, ios_base::openmode which);
 
-#include <array>
 #include <cassert>
+#include <concepts>
 #include <sstream>
 #include <string>
 #include <string_view>
@@ -27,41 +27,56 @@
 #include "test_convertible.h"
 #include "test_macros.h"
 
-struct SomeObject {};
-
 template <typename CharT>
-void test_constraints() {
+void test_sfinae() {
+  struct SomeObject {};
+
   // `const CharT*`
-  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
-  //                                const CharT*,
-  //                                std::ios_base::openmode>());
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+                                        const CharT*,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+                                  const CharT*,
+                                  std::ios_base::openmode>());
   // `std::basic_string_view<CharT>`
-  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
-  //                                std::basic_string_view<CharT, std::char_traits<CharT>>,
-  //                                std::ios_base::openmode>());
-  // // `std::basic_string<CharT>`
-  // static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                std::basic_string<CharT>,
-  //                                std::ios_base::openmode>());
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+                                        const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+                                  const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string<CharT>,
+                                  std::ios_base::openmode>());
 
-  // // Non-convertible to std::`basic_string_view<CharT>`
-  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                 int,
-  //                                 std::ios_base::openmode>());
-  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                 const int&,
-  //                                 std::ios_base::openmode>());
-  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                 SomeObject,
-  //                                 std::ios_base::openmode>());
-  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                 const SomeObject&,
-  //                                 std::ios_base::openmode>());
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const int,
+                               std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode>());
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode>());
 
-  // // Mode
-  // static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-  //                                 std::basic_string<CharT>,
-  //                                 SomeObject>());
+  // Mode
+  static_assert(
+      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               const SomeObject>);
+  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const SomeObject>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -72,30 +87,29 @@ template <class CharT>
 static void test() {
   // const CharT*
   {
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
         CS("zmt"), std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    assert(ss.str() == CS("zmt"));
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        csv, std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    const std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
   }
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
index 501f76d00acfee..949516d061adce 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -25,22 +25,22 @@
 #include "test_macros.h"
 
 template <typename S, typename T>
-concept HasMember = requires(S s, const T& sv) {
+concept HasStr = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
-struct SomeObject {};
-
 template <typename CharT>
-void test_constraints() {
-  static_assert(HasMember<std::basic_istringstream<CharT>, const CharT*>);
-  static_assert(HasMember<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
-  static_assert(HasMember<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
+void test_sfinae() {
+  struct SomeObject {};
+
+  static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
+  static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
 
-  static_assert(!HasMember<std::basic_istringstream<CharT>, char>);
-  static_assert(!HasMember<std::basic_istringstream<CharT>, int>);
-  static_assert(!HasMember<std::basic_istringstream<CharT>, SomeObject>);
-  static_assert(!HasMember<std::basic_istringstream<CharT>, std::nullptr_t>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, char>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, int>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, SomeObject>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, std::nullptr_t>);
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -63,10 +63,10 @@ void test() {
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
 
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.alloc.pass.cpp
new file mode 100644
index 00000000000000..0b3515dc543b77
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.alloc.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_ostringstream(const T& t, const Allocator& a);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string_view<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string<CharT>,
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  const test_allocator<CharT>>());
+
+  // Allocator
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               const NonAllocator>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp
index 59659505055f5f..b63536f0e03719 100644
--- a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.alloc.pass.cpp
@@ -16,8 +16,8 @@
 // template<class T>
 //   basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);
 
-#include <array>
 #include <cassert>
+#include <concepts>
 #include <sstream>
 #include <string>
 #include <string_view>
@@ -27,56 +27,80 @@
 #include "test_convertible.h"
 #include "test_macros.h"
 
-struct SomeObject {};
-struct NonAllocator {};
-
 template <typename CharT>
-void test_constraints() {
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
   // `const CharT*`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
                                  const CharT*,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
   // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        std::basic_string_view<CharT>,
+                                        std::ios_base::openmode,
+                                        test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string_view<CharT>,
+                                 const std::basic_string_view<CharT>,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
   // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string<CharT>,
+                                 const std::basic_string<CharT>,
                                  std::ios_base::openmode,
-                                 test_allocator<CharT>>());
+                                 const test_allocator<CharT>>());
 
-  // Non-convertible to std::`basic_string_view<CharT>`
-  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  int,
-                                  std::ios_base::openmode,
-                                  test_allocator<CharT>>());
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const int,
+                               std::ios_base::openmode,
+                               const test_allocator<CharT>>);
   static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const int&,
-                                  std::ios_base::openmode,
-                                  test_allocator<CharT>>());
-  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  SomeObject,
+                                  const int,
                                   std::ios_base::openmode,
-                                  test_allocator<CharT>>());
+                                  const test_allocator<CharT>>());
+
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               std::ios_base::openmode,
+                               const test_allocator<CharT>>);
   static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject&,
+                                  const SomeObject,
                                   std::ios_base::openmode,
-                                  test_allocator<CharT>>());
+                                  const test_allocator<CharT>>());
 
   // Mode
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               SomeObject,
+                               const NonAllocator>);
   static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  std::basic_string<CharT>,
+                                  const std::basic_string_view<CharT>,
                                   SomeObject,
-                                  NonAllocator>());
+                                  const NonAllocator>());
 
   // Allocator
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               std::ios_base::openmode,
+                               const NonAllocator>);
   static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  std::basic_string<CharT>,
+                                  const std::basic_string_view<CharT>,
                                   std::ios_base::openmode,
-                                  NonAllocator>());
+                                  const NonAllocator>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -85,47 +109,36 @@ void test_constraints() {
 
 template <class CharT>
 static void test() {
-  using namespace std::string_literals;
-  using namespace std::string_view_literals;
+  const test_allocator<CharT> ca;
 
   // const CharT*
   {
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"));
-    assert(ss.view() == SV("zmt"));
-  }
-  {
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        CS("zmt"), std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(SV("zmt"));
-    assert(ss.view() == SV("zmt"));
-  }
-  {
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        SV("zmt"), std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    const auto csv = SV("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
-    const std::basic_string<CharT> s(ST("zmt"));
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s);
-    assert(ss.view() == SV("zmt"));
-  }
-  {
-    const std::basic_string<CharT> s(ST("zmt"));
-    const std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(s, std::ios_base::binary);
-    assert(ss.view() == SV("zmt"));
+    const auto cs = ST("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
   }
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
   return 0;
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
new file mode 100644
index 00000000000000..7a87f1bfc73b64
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_ostringstream(const T& t, ios_base::openmode which);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>>,
+                                        const CharT*,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>>,
+                                  const CharT*,
+                                  std::ios_base::openmode>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>>,
+                                        const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>>,
+                                  const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string<CharT>,
+                                  std::ios_base::openmode>());
+
+  // String-view-like
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const int,
+                               std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode>());
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const SomeObject,
+                               std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode>());
+
+  // Mode
+  static_assert(
+      !std::constructible_from<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                               const std::basic_string_view<CharT>,
+                               const SomeObject>);
+  static_assert(!test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const SomeObject>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  // const CharT*
+  {
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
index 018be464f61d3c..d0433c9347aa8c 100644
--- a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.members/str.string_view.pass.cpp
@@ -25,22 +25,22 @@
 #include "test_macros.h"
 
 template <typename S, typename T>
-concept HasMember = requires(S s, const T& sv) {
+concept HasStr = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
-struct SomeObject {};
-
 template <typename CharT>
-void test_constraints() {
-  static_assert(HasMember<std::basic_ostringstream<CharT>, const CharT*>);
-  static_assert(HasMember<std::basic_ostringstream<CharT>, std::basic_string_view<CharT>>);
-  static_assert(HasMember<std::basic_ostringstream<CharT>, std::basic_string<CharT>>);
+void test_sfinae() {
+  struct SomeObject {};
+
+  static_assert(HasStr<std::basic_ostringstream<CharT>, const CharT*>);
+  static_assert(HasStr<std::basic_ostringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasStr<std::basic_ostringstream<CharT>, std::basic_string<CharT>>);
 
-  static_assert(!HasMember<std::basic_ostringstream<CharT>, char>);
-  static_assert(!HasMember<std::basic_ostringstream<CharT>, int>);
-  static_assert(!HasMember<std::basic_ostringstream<CharT>, SomeObject>);
-  static_assert(!HasMember<std::basic_ostringstream<CharT>, std::nullptr_t>);
+  static_assert(!HasStr<std::basic_ostringstream<CharT>, char>);
+  static_assert(!HasStr<std::basic_ostringstream<CharT>, int>);
+  static_assert(!HasStr<std::basic_ostringstream<CharT>, SomeObject>);
+  static_assert(!HasStr<std::basic_ostringstream<CharT>, std::nullptr_t>);
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -63,10 +63,10 @@ void test() {
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
 
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.alloc.pass.cpp
new file mode 100644
index 00000000000000..264ed301e9ffd8
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.alloc.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringbuf(const T& t, const Allocator& a);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string_view<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string<CharT>,
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  const test_allocator<CharT>>());
+
+  // Allocator
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
new file mode 100644
index 00000000000000..872215b5342eb8
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        std::basic_string_view<CharT>,
+                                        std::ios_base::openmode,
+                                        test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string_view<CharT>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string<CharT>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const int,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  // Mode
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         SomeObject,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  SomeObject,
+                                  const NonAllocator>());
+
+  // Allocator
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         std::ios_base::openmode,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  std::ios_base::openmode,
+                                  const NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
new file mode 100644
index 00000000000000..efb63be6bcb6e2
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringbuf(const T& t, ios_base::openmode which);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>>,
+                                        const CharT*,
+                                        std::ios_base::openmode>);
+  static_assert(
+      !test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>>, const CharT*, std::ios_base::openmode>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>>,
+                                        const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>>,
+                                  const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string<CharT>,
+                                  std::ios_base::openmode>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const int,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode>());
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode>());
+
+  // Mode
+  static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         const SomeObject>);
+  static_assert(!test_convertible<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const SomeObject>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  // const CharT*
+  {
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
index f0fbc7d273f950..ac76756d0e8a3b 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.string_view.pass.cpp
@@ -24,22 +24,22 @@
 #include "test_macros.h"
 
 template <typename S, typename T>
-concept HasMember = requires(S s, const T& sv) {
+concept HasStr = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
-struct SomeObject {};
-
 template <typename CharT>
-void test_constraints() {
-  static_assert(HasMember<std::basic_stringbuf<CharT>, const CharT*>);
-  static_assert(HasMember<std::basic_stringbuf<CharT>, std::basic_string_view<CharT>>);
-  static_assert(HasMember<std::basic_stringbuf<CharT>, std::basic_string<CharT>>);
+void test_sfinae() {
+  struct SomeObject {};
+
+  static_assert(HasStr<std::basic_stringbuf<CharT>, const CharT*>);
+  static_assert(HasStr<std::basic_stringbuf<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasStr<std::basic_stringbuf<CharT>, std::basic_string<CharT>>);
 
-  static_assert(!HasMember<std::basic_stringbuf<CharT>, char>);
-  static_assert(!HasMember<std::basic_stringbuf<CharT>, int>);
-  static_assert(!HasMember<std::basic_stringbuf<CharT>, SomeObject>);
-  static_assert(!HasMember<std::basic_stringbuf<CharT>, std::nullptr_t>);
+  static_assert(!HasStr<std::basic_stringbuf<CharT>, char>);
+  static_assert(!HasStr<std::basic_stringbuf<CharT>, int>);
+  static_assert(!HasStr<std::basic_stringbuf<CharT>, SomeObject>);
+  static_assert(!HasStr<std::basic_stringbuf<CharT>, std::nullptr_t>);
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -62,10 +62,10 @@ void test() {
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
 
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.alloc.pass.cpp
new file mode 100644
index 00000000000000..3fe41d57341c30
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.alloc.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringstream(const T& t, const Allocator& a);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string_view<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 std::basic_string_view<CharT>,
+                                 test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string<CharT>,
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  const test_allocator<CharT>>());
+
+  // Allocator
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
new file mode 100644
index 00000000000000..e0fdcc64c818dd
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+  struct NonAllocator {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const CharT*,
+                                        test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const CharT*,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        std::basic_string_view<CharT>,
+                                        std::ios_base::openmode,
+                                        test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string_view<CharT>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                 const std::basic_string<CharT>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const int,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  // Mode
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         SomeObject,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  SomeObject,
+                                  const NonAllocator>());
+
+  // Allocator
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         std::ios_base::openmode,
+                                         const NonAllocator>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  std::ios_base::openmode,
+                                  const NonAllocator>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  const test_allocator<CharT> ca;
+
+  // const CharT*
+  {
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
new file mode 100644
index 00000000000000..0d5158a97b816c
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
+// class basic_stringstream
+
+// template<class T>
+//   basic_stringstream(const T& t, ios_base::openmode which);
+
+#include <cassert>
+#include <concepts>
+#include <sstream>
+#include <string>
+#include <string_view>
+
+#include "make_string.h"
+#include "test_allocator.h"
+#include "test_convertible.h"
+#include "test_macros.h"
+
+template <typename CharT>
+void test_sfinae() {
+  struct SomeObject {};
+
+  // `const CharT*`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>>,
+                                        const CharT*,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>>,
+                                  const CharT*,
+                                  std::ios_base::openmode>());
+  // `std::basic_string_view<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>>,
+                                        const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>>,
+                                  const std::basic_string_view<CharT, std::char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+  // `std::basic_string<CharT>`
+  static_assert(std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                        const std::basic_string<CharT>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string<CharT>,
+                                  std::ios_base::openmode>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const int,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const int,
+                                  std::ios_base::openmode>());
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const SomeObject,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const SomeObject,
+                                  std::ios_base::openmode>());
+
+  // Mode
+  static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                         const std::basic_string_view<CharT>,
+                                         const SomeObject>);
+  static_assert(!test_convertible<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+                                  const std::basic_string_view<CharT>,
+                                  const SomeObject>());
+}
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S) MAKE_STRING(CharT, S)
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT>
+static void test() {
+  // const CharT*
+  {
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string_view<CharT>
+  {
+    const auto csv = SV("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // std::basic_string<CharT>
+  {
+    const auto cs = ST("zmt");
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+}
+
+int main(int, char**) {
+  test_sfinae<char>();
+  test<char>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_sfinae<wchar_t>();
+  test<wchar_t>();
+#endif
+  return 0;
+}
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
index 76c2963580911b..f575c2f4d9622b 100644
--- a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.members/str.string_view.pass.cpp
@@ -25,22 +25,22 @@
 #include "test_macros.h"
 
 template <typename S, typename T>
-concept HasMember = requires(S s, const T& sv) {
+concept HasStr = requires(S s, const T& sv) {
   { s.str(sv) };
 };
 
-struct SomeObject {};
-
 template <typename CharT>
-void test_constraints() {
-  static_assert(HasMember<std::basic_stringstream<CharT>, const CharT*>);
-  static_assert(HasMember<std::basic_stringstream<CharT>, std::basic_string_view<CharT>>);
-  static_assert(HasMember<std::basic_stringstream<CharT>, std::basic_string<CharT>>);
+void test_sfinae() {
+  struct SomeObject {};
+
+  static_assert(HasStr<std::basic_stringstream<CharT>, const CharT*>);
+  static_assert(HasStr<std::basic_stringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasStr<std::basic_stringstream<CharT>, std::basic_string<CharT>>);
 
-  static_assert(!HasMember<std::basic_stringstream<CharT>, char>);
-  static_assert(!HasMember<std::basic_stringstream<CharT>, int>);
-  static_assert(!HasMember<std::basic_stringstream<CharT>, SomeObject>);
-  static_assert(!HasMember<std::basic_stringstream<CharT>, std::nullptr_t>);
+  static_assert(!HasStr<std::basic_stringstream<CharT>, char>);
+  static_assert(!HasStr<std::basic_stringstream<CharT>, int>);
+  static_assert(!HasStr<std::basic_stringstream<CharT>, SomeObject>);
+  static_assert(!HasStr<std::basic_stringstream<CharT>, std::nullptr_t>);
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -63,10 +63,10 @@ void test() {
 }
 
 int main(int, char**) {
-  test_constraints<char>();
+  test_sfinae<char>();
   test<char>();
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-  test_constraints<wchar_t>();
+  test_sfinae<wchar_t>();
   test<wchar_t>();
 #endif
 

>From c228f06c1c2dbefe6fcf2817c9ee202c1836194c Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 18:46:15 +0200
Subject: [PATCH 04/17] Done: Implementation and tests

---
 libcxx/include/sstream                        | 32 ++++++++++---------
 .../string_view.mode.alloc.pass.cpp           |  8 +++--
 .../stringbuf.cons/string_view.mode.pass.cpp  |  9 ++++--
 .../string_view.mode.alloc.pass.cpp           |  9 ++++--
 .../string_view.mode.pass.cpp                 |  9 ++++--
 5 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 6f6da1cb9ba076..af026a0a42b9d5 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -416,9 +416,9 @@ public:
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
   _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
-      : basic_stringbuf(__which, __a) {
+      : __hm_(nullptr), __mode_(__which | ios_base::in | ios_base::out) {
     basic_string_view<_CharT, _Traits> __sv = __t;
-    __str_                                  = __sv;
+    __str_                                  = string_type(__sv, __a);
     __init_buf_ptrs();
   }
 
@@ -898,16 +898,17 @@ public:
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
-      : basic_istringstream(__t, __which, _Allocator()) {}
+  _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
+      : basic_istringstream(__t, __which | ios_base::in, _Allocator()) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_istringstream(const _Tp& __t, const _Allocator& __a) : basic_istringstream(__t, ios_base::in, __a) {}
+  _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, const _Allocator& __a)
+      : basic_istringstream(__t, ios_base::in, __a) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+  _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
       : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
 
 #endif //  _LIBCPP_STD_VER >= 26
@@ -1031,16 +1032,17 @@ public:
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out)
-      : basic_ostringstream(__t, __which, _Allocator()) {}
+  _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out)
+      : basic_ostringstream(__t, __which | ios_base::out, _Allocator()) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_ostringstream(const _Tp& __t, const _Allocator& __a) : basic_ostringstream(__t, ios_base::out, __a) {}
+  _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, const _Allocator& __a)
+      : basic_ostringstream(__t, ios_base::out, __a) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+  _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
       : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
 
 #endif //  _LIBCPP_STD_VER >= 26
@@ -1168,19 +1170,19 @@ public:
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  explicit basic_stringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out | ios_base::in)
+  _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const _Tp& __t,
+                                                    ios_base::openmode __which = ios_base::out | ios_base::in)
       : basic_stringstream(__t, __which, _Allocator()) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_stringstream(const _Tp& __t, const _Allocator& __a)
+  _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, const _Allocator& __a)
       : basic_stringstream(__t, ios_base::out | ios_base::in, __a) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
-  basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
-      : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)),
-        __sb_(__t, __which | ios_base::out | ios_base::in, __a) {}
+  _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
+      : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}
 
 #endif //  _LIBCPP_STD_VER >= 26
 
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
index 872215b5342eb8..6f304125babb4d 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp
@@ -110,21 +110,23 @@ static void test() {
   // const CharT*
   {
     std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        CS("zmt"), std::ios_base::binary, ca);
+        CS("zmt"), std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        csv, std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        cs, std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.get_allocator() == ca);
   }
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
index efb63be6bcb6e2..893a27befb794a 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
@@ -83,19 +83,22 @@ template <class CharT>
 static void test() {
   // const CharT*
   {
-    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), std::ios_base::binary);
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        csv, std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        cs, std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
 }
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
index e0fdcc64c818dd..be3d5d8b02059f 100644
--- a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.alloc.pass.cpp
@@ -102,6 +102,7 @@ void test_sfinae() {
 #define CS(S) MAKE_CSTRING(CharT, S)
 #define ST(S) MAKE_STRING(CharT, S)
 #define SV(S) MAKE_STRING_VIEW(CharT, S)
+#include <print>
 
 template <class CharT>
 static void test() {
@@ -110,21 +111,23 @@ static void test() {
   // const CharT*
   {
     std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        CS("zmt"), std::ios_base::binary, ca);
+        CS("zmt"), std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        csv, std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        cs, std::ios_base::out | std::ios_base::in, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
index 0d5158a97b816c..e2ad1d447a7e27 100644
--- a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
@@ -84,19 +84,22 @@ template <class CharT>
 static void test() {
   // const CharT*
   {
-    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), std::ios_base::binary);
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        CS("zmt"), std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string_view<CharT>
   {
     const auto csv = SV("zmt");
-    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        csv, std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string<CharT>
   {
     const auto cs = ST("zmt");
-    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
+        cs, std::ios_base::out | std::ios_base::in);
     assert(ss.str() == CS("zmt"));
   }
 }

>From ed9749447322099cec17763caf0579920076fd40 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 18:46:54 +0200
Subject: [PATCH 05/17] Generated FTM

---
 libcxx/docs/FeatureTestMacroTable.rst            |  2 +-
 libcxx/include/version                           |  2 +-
 .../sstream.version.compile.pass.cpp             | 16 +++++-----------
 .../version.version.compile.pass.cpp             | 16 +++++-----------
 4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index a5c6fa22cec06c..5a0bbf7df0b05c 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -440,7 +440,7 @@ Status
     --------------------------------------------------- -----------------
     ``__cpp_lib_span_initializer_list``                 ``202311L``
     --------------------------------------------------- -----------------
-    ``__cpp_lib_sstream_from_string_view``              *unimplemented*
+    ``__cpp_lib_sstream_from_string_view``              ``202306L``
     --------------------------------------------------- -----------------
     ``__cpp_lib_submdspan``                             *unimplemented*
     --------------------------------------------------- -----------------
diff --git a/libcxx/include/version b/libcxx/include/version
index e4dbb7bdd5fc2c..4fbba978b6b0e1 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -508,7 +508,7 @@ __cpp_lib_within_lifetime                               202306L <type_traits>
 // # define __cpp_lib_smart_ptr_owner_equality             202306L
 # define __cpp_lib_span_at                              202311L
 # define __cpp_lib_span_initializer_list                202311L
-// # define __cpp_lib_sstream_from_string_view             202306L
+# define __cpp_lib_sstream_from_string_view             202306L
 // # define __cpp_lib_submdspan                            202306L
 // # define __cpp_lib_text_encoding                        202306L
 # undef  __cpp_lib_to_chars
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/sstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/sstream.version.compile.pass.cpp
index 78e17e5f1ddb56..ad3c8e4012ecff 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/sstream.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/sstream.version.compile.pass.cpp
@@ -56,17 +56,11 @@
 
 #elif TEST_STD_VER > 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_sstream_from_string_view
-#     error "__cpp_lib_sstream_from_string_view should be defined in c++26"
-#   endif
-#   if __cpp_lib_sstream_from_string_view != 202306L
-#     error "__cpp_lib_sstream_from_string_view should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_sstream_from_string_view
-#     error "__cpp_lib_sstream_from_string_view should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_sstream_from_string_view
+#   error "__cpp_lib_sstream_from_string_view should be defined in c++26"
+# endif
+# if __cpp_lib_sstream_from_string_view != 202306L
+#   error "__cpp_lib_sstream_from_string_view should have the value 202306L in c++26"
 # endif
 
 #endif // TEST_STD_VER > 23
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index 29f0ba89330bb9..60c43b7eb082d8 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -7315,17 +7315,11 @@
 #   error "__cpp_lib_ssize should have the value 201902L in c++26"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_sstream_from_string_view
-#     error "__cpp_lib_sstream_from_string_view should be defined in c++26"
-#   endif
-#   if __cpp_lib_sstream_from_string_view != 202306L
-#     error "__cpp_lib_sstream_from_string_view should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_sstream_from_string_view
-#     error "__cpp_lib_sstream_from_string_view should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_sstream_from_string_view
+#   error "__cpp_lib_sstream_from_string_view should be defined in c++26"
+# endif
+# if __cpp_lib_sstream_from_string_view != 202306L
+#   error "__cpp_lib_sstream_from_string_view should have the value 202306L in c++26"
 # endif
 
 # if !defined(_LIBCPP_VERSION)

>From 23d4a575ae578641dd31378f70ce0b1e2d94cc11 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 19:14:19 +0200
Subject: [PATCH 06/17] Fixed transitive includes

---
 libcxx/test/libcxx/transitive_includes/cxx03.csv | 5 +++++
 libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 +
 libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 +
 libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 +
 libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 +
 libcxx/test/libcxx/transitive_includes/cxx23.csv | 1 +
 libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 +
 7 files changed, 11 insertions(+)

diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index d4c22023db7a06..08b2a7431c8151 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -742,6 +742,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream type_traits
 sstream version
 stack compare
@@ -833,13 +834,17 @@ system_error type_traits
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
 thread chrono
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
 thread cstring
 thread ctime
+thread cwchar
 thread functional
 thread iosfwd
 thread limits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 5eb839a3aa7a66..2039c60e79f033 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -748,6 +748,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream type_traits
 sstream version
 stack compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 7b372fb37dcd58..3d3eb2822722ca 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -750,6 +750,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream type_traits
 sstream version
 stack compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 7b372fb37dcd58..3d3eb2822722ca 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -750,6 +750,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream type_traits
 sstream version
 stack compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 9b4915a468d1cf..557b08915ddeb9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -755,6 +755,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream type_traits
 sstream version
 stack compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 7c7099d176f18b..61b063b08b0b29 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -519,6 +519,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream version
 stack compare
 stack cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 7c7099d176f18b..61b063b08b0b29 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -519,6 +519,7 @@ sstream cstddef
 sstream istream
 sstream ostream
 sstream string
+sstream string_view
 sstream version
 stack compare
 stack cstddef

>From d9e93cf31948f3819fa5f105d3a3d3a510114beb Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 19:31:17 +0200
Subject: [PATCH 07/17] Disabled failing tests with new constructors in c++26
 mode

---
 .../stringbuf/stringbuf.members/str.move.pass.cpp             | 2 ++
 .../string.streams/stringbuf/stringbuf.members/str.pass.cpp   | 2 ++
 .../string.streams/stringbuf/stringbuf.members/view.pass.cpp  | 2 ++
 .../stringbuf/stringbuf.virtuals/seekoff.pass.cpp             | 4 ++++
 .../stringbuf/stringbuf.virtuals/seekpos.pass.cpp             | 4 ++++
 5 files changed, 14 insertions(+)

diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
index 9d75bf938ad756..46dd41f7d2235d 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
@@ -55,6 +55,7 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
+#if TEST_STD_VER < 26
   {
     auto src = StringBuf("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -79,6 +80,7 @@ static void test_altered_sequence_pointers() {
     assert(dest.str().empty());
     assert(dest.view().empty());
   }
+#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**) {
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
index 8cd3840b6841f7..35fe123cac9466 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -28,6 +28,7 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
+#if TEST_STD_VER < 26
   {
     StringBuf src("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -48,6 +49,7 @@ static void test_altered_sequence_pointers() {
     LIBCPP_ASSERT(str == "o wor");
     LIBCPP_ASSERT(dest.str() == "o wor");
   }
+#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**)
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
index 67ff506bb9dc48..e2d39a2c0df57f 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
@@ -59,6 +59,7 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
+#if TEST_STD_VER < 26
   {
     auto src = StringBuf("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -75,6 +76,7 @@ static void test_altered_sequence_pointers() {
     assert(dest.view() == dest.str());
     LIBCPP_ASSERT(dest.view() == "o wor");
   }
+#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**) {
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
index 2bd558557e8337..0d4dd2a948e0b2 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -45,6 +45,7 @@ int main(int, char**)
         assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0);
         assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0);
     }
+#if TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789", std::ios_base::in);
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
@@ -78,6 +79,7 @@ int main(int, char**)
         assert(sb.sputc('c') == 'c');
         assert(sb.str() == "012a456c89");
     }
+#endif // TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789");
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
@@ -106,6 +108,7 @@ int main(int, char**)
         assert(sb.str() == "0123456c89");
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#  if TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789", std::ios_base::in);
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
@@ -139,6 +142,7 @@ int main(int, char**)
         assert(sb.sputc(L'c') == L'c');
         assert(sb.str() == L"012a456c89");
     }
+#  endif // TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789");
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
index 68bebf56ebf6ab..8e00ee27841c3c 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -21,6 +21,7 @@
 
 int main(int, char**)
 {
+#if TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789", std::ios_base::in);
         assert(sb.pubseekpos(3, std::ios_base::out) == -1);
@@ -36,6 +37,7 @@ int main(int, char**)
         assert(sb.sputc('a') == 'a');
         assert(sb.str() == "012a456789");
     }
+#endif // TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789");
         assert(sb.pubseekpos(3, std::ios_base::in) == 3);
@@ -49,6 +51,7 @@ int main(int, char**)
         assert(sb.str() == "0123456789");
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#  if TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789", std::ios_base::in);
         assert(sb.pubseekpos(3, std::ios_base::out) == -1);
@@ -64,6 +67,7 @@ int main(int, char**)
         assert(sb.sputc(L'a') == L'a');
         assert(sb.str() == L"012a456789");
     }
+#  endif // TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789");
         assert(sb.pubseekpos(3, std::ios_base::in) == 3);

>From 879bc439e1f9e6fc16ca2963e27d1633ba0a4f21 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Feb 2024 20:15:21 +0200
Subject: [PATCH 08/17] Fixed `std::basic_stringbuf`

---
 libcxx/include/sstream                                        | 2 +-
 .../stringbuf/stringbuf.members/str.move.pass.cpp             | 2 --
 .../string.streams/stringbuf/stringbuf.members/str.pass.cpp   | 2 --
 .../string.streams/stringbuf/stringbuf.members/view.pass.cpp  | 2 --
 .../stringbuf/stringbuf.virtuals/seekoff.pass.cpp             | 4 ----
 .../stringbuf/stringbuf.virtuals/seekpos.pass.cpp             | 4 ----
 6 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index af026a0a42b9d5..f2be4c9bc8b1b1 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -416,7 +416,7 @@ public:
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
   _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
-      : __hm_(nullptr), __mode_(__which | ios_base::in | ios_base::out) {
+      : __hm_(nullptr), __mode_(__which) {
     basic_string_view<_CharT, _Traits> __sv = __t;
     __str_                                  = string_type(__sv, __a);
     __init_buf_ptrs();
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
index 46dd41f7d2235d..9d75bf938ad756 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.move.pass.cpp
@@ -55,7 +55,6 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
-#if TEST_STD_VER < 26
   {
     auto src = StringBuf("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -80,7 +79,6 @@ static void test_altered_sequence_pointers() {
     assert(dest.str().empty());
     assert(dest.view().empty());
   }
-#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**) {
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
index 35fe123cac9466..8cd3840b6841f7 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -28,7 +28,6 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
-#if TEST_STD_VER < 26
   {
     StringBuf src("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -49,7 +48,6 @@ static void test_altered_sequence_pointers() {
     LIBCPP_ASSERT(str == "o wor");
     LIBCPP_ASSERT(dest.str() == "o wor");
   }
-#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**)
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
index e2d39a2c0df57f..67ff506bb9dc48 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.members/view.pass.cpp
@@ -59,7 +59,6 @@ struct StringBuf : std::stringbuf {
 };
 
 static void test_altered_sequence_pointers() {
-#if TEST_STD_VER < 26
   {
     auto src = StringBuf("hello world", std::ios_base::in);
     src.public_setg(4, 6, 9);
@@ -76,7 +75,6 @@ static void test_altered_sequence_pointers() {
     assert(dest.view() == dest.str());
     LIBCPP_ASSERT(dest.view() == "o wor");
   }
-#endif // TEST_STD_VER < 26
 }
 
 int main(int, char**) {
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
index 0d4dd2a948e0b2..2bd558557e8337 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -45,7 +45,6 @@ int main(int, char**)
         assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0);
         assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0);
     }
-#if TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789", std::ios_base::in);
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
@@ -79,7 +78,6 @@ int main(int, char**)
         assert(sb.sputc('c') == 'c');
         assert(sb.str() == "012a456c89");
     }
-#endif // TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789");
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
@@ -108,7 +106,6 @@ int main(int, char**)
         assert(sb.str() == "0123456c89");
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-#  if TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789", std::ios_base::in);
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
@@ -142,7 +139,6 @@ int main(int, char**)
         assert(sb.sputc(L'c') == L'c');
         assert(sb.str() == L"012a456c89");
     }
-#  endif // TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789");
         assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
index 8e00ee27841c3c..68bebf56ebf6ab 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -21,7 +21,6 @@
 
 int main(int, char**)
 {
-#if TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789", std::ios_base::in);
         assert(sb.pubseekpos(3, std::ios_base::out) == -1);
@@ -37,7 +36,6 @@ int main(int, char**)
         assert(sb.sputc('a') == 'a');
         assert(sb.str() == "012a456789");
     }
-#endif // TEST_STD_VER < 26
     {
         std::stringbuf sb("0123456789");
         assert(sb.pubseekpos(3, std::ios_base::in) == 3);
@@ -51,7 +49,6 @@ int main(int, char**)
         assert(sb.str() == "0123456789");
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-#  if TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789", std::ios_base::in);
         assert(sb.pubseekpos(3, std::ios_base::out) == -1);
@@ -67,7 +64,6 @@ int main(int, char**)
         assert(sb.sputc(L'a') == L'a');
         assert(sb.str() == L"012a456789");
     }
-#  endif // TEST_STD_VER < 26
     {
         std::wstringbuf sb(L"0123456789");
         assert(sb.pubseekpos(3, std::ios_base::in) == 3);

>From 6483ddb1c8d59d41c7ed5aa356bb592ec49ce019 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 12 Feb 2024 15:06:14 +0200
Subject: [PATCH 09/17] Addressed some comments

---
 libcxx/include/sstream                                        | 2 +-
 .../istringstream.cons/string_view.mode.alloc.pass.cpp        | 4 ++--
 .../istringstream.members/str.string_view.pass.cpp            | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index f2be4c9bc8b1b1..2fcfe5f73ce46c 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -899,7 +899,7 @@ public:
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
   _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
-      : basic_istringstream(__t, __which | ios_base::in, _Allocator()) {}
+      : basic_istringstream(__t, __which, _Allocator()) {}
 
   template <class _Tp>
     requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index a8c4b80cb032bb..52a3871260be29 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -120,14 +120,14 @@ static void test() {
   }
   // std::basic_string_view<CharT>
   {
-    const auto csv = SV("zmt");
+    const std::basic_string_view<CharT> csv = SV("zmt");
     std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
-    const auto cs = ST("zmt");
+    const std::basic_string<CharT> cs = ST("zmt");
     std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
index 949516d061adce..a1c0d7e9f5b5bf 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -34,10 +34,11 @@ void test_sfinae() {
   struct SomeObject {};
 
   static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
+  static_assert(HasStr<std::basic_istringstream<CharT>, CharT*>);
   static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
   static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
 
-  static_assert(!HasStr<std::basic_istringstream<CharT>, char>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, CharT>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, int>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, SomeObject>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, std::nullptr_t>);

>From aeee4699cc63fcc42749715c4217131c692f1393 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 12 Feb 2024 15:42:27 +0200
Subject: [PATCH 10/17] WIP: adding `constexpr_char_traits`

---
 .../string_view.mode.alloc.pass.cpp           | 106 +++++++++---------
 1 file changed, 56 insertions(+), 50 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 52a3871260be29..f94aa5412c7b35 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -22,85 +22,90 @@
 #include <string>
 #include <string_view>
 
+#include "constexpr_char_traits.h"
 #include "make_string.h"
+#include "nasty_string.h"
 #include "test_allocator.h"
 #include "test_convertible.h"
 #include "test_macros.h"
 
+
 template <typename CharT>
 void test_sfinae() {
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+  using SSTREAM  = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+  using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
+
   struct SomeObject {};
   struct NonAllocator {};
 
+  // nasty_char
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
+  static_assert(
+      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
   // `const CharT*`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        const CharT*,
-                                        test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 const CharT*,
+  static_assert(std::constructible_from<SSTREAM, const CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM, const CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
+
+  // `std::basic_string_view<CharT>`
+  static_assert(
+      std::constructible_from<SSTREAM, std::basic_string_view<CharT>, std::ios_base::openmode, test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM,
+                                 const std::basic_string_view<CharT>,
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
-  // `std::basic_string_view<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        std::basic_string_view<CharT>,
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
                                         std::ios_base::openmode,
                                         test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 const std::basic_string_view<CharT>,
+  static_assert(test_convertible<CSSTREAM,
+                                 const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
+
   // `std::basic_string<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  static_assert(std::constructible_from<SSTREAM,
                                         const std::basic_string<CharT>,
                                         std::ios_base::openmode,
                                         const test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
+  static_assert(test_convertible<SSTREAM,
                                  const std::basic_string<CharT>,
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
 
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const std::basic_string<CharT, constexpr_char_traits<CharT>>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM,
+                                 const std::basic_string<CharT, constexpr_char_traits<CharT>>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+
   // String-view-like
-  static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const int,
-                               std::ios_base::openmode,
-                               const test_allocator<CharT>>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const int,
-                                  std::ios_base::openmode,
-                                  const test_allocator<CharT>>());
+  static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
 
   static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const SomeObject,
-                               std::ios_base::openmode,
-                               const test_allocator<CharT>>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject,
-                                  std::ios_base::openmode,
-                                  const test_allocator<CharT>>());
+      !std::constructible_from<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>());
 
   // Mode
-  static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const std::basic_string_view<CharT>,
-                               SomeObject,
-                               const NonAllocator>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const std::basic_string_view<CharT>,
-                                  SomeObject,
-                                  const NonAllocator>());
+  static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, SomeObject, const NonAllocator>);
+  static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, SomeObject, const NonAllocator>());
 
   // Allocator
+  static_assert(!std::constructible_from<SSTREAM,
+                                         const std::basic_string_view<CharT>,
+                                         std::ios_base::openmode,
+                                         const NonAllocator>);
   static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const std::basic_string_view<CharT>,
-                               std::ios_base::openmode,
-                               const NonAllocator>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const std::basic_string_view<CharT>,
-                                  std::ios_base::openmode,
-                                  const NonAllocator>());
+      !test_convertible<SSTREAM, const std::basic_string_view<CharT>, std::ios_base::openmode, const NonAllocator>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -109,26 +114,27 @@ void test_sfinae() {
 
 template <class CharT>
 static void test() {
+  using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+
   const test_allocator<CharT> ca;
 
   // const CharT*
   {
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        CS("zmt"), std::ios_base::binary, ca);
+    SSTREAM ss(CS("zmt"), std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
     const std::basic_string_view<CharT> csv = SV("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary, ca);
+    SSTREAM ss(csv, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
     const std::basic_string<CharT> cs = ST("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary, ca);
+    SSTREAM ss(cs, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }

>From bc67da4c1dec6275f2f10e79d39e4f4c0a5da980 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Wed, 14 Feb 2024 16:36:42 +0200
Subject: [PATCH 11/17] Updated:
 libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp

---
 .../string_view.mode.alloc.pass.cpp           | 68 ++++++++++++++-----
 .../std/input.output/string.streams/types.h   | 44 ++++++++++++
 2 files changed, 96 insertions(+), 16 deletions(-)
 create mode 100644 libcxx/test/std/input.output/string.streams/types.h

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index f94aa5412c7b35..011367a5fb5969 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -29,20 +29,19 @@
 #include "test_convertible.h"
 #include "test_macros.h"
 
+#include "../../types.h"
 
 template <typename CharT>
 void test_sfinae() {
-  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
   using SSTREAM  = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
   using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
 
-  struct SomeObject {};
-  struct NonAllocator {};
+  // `CharT*`
+  static_assert(std::constructible_from<SSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
 
-  // nasty_char
-  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
-  static_assert(
-      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+  static_assert(std::constructible_from<CSSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
 
   // `const CharT*`
   static_assert(std::constructible_from<SSTREAM, const CharT*, test_allocator<CharT>>);
@@ -52,17 +51,19 @@ void test_sfinae() {
   static_assert(test_convertible<CSSTREAM, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
 
   // `std::basic_string_view<CharT>`
-  static_assert(
-      std::constructible_from<SSTREAM, std::basic_string_view<CharT>, std::ios_base::openmode, test_allocator<CharT>>);
+  static_assert(std::constructible_from<SSTREAM,
+                                        const std::basic_string_view<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM,
                                  const std::basic_string_view<CharT>,
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
 
   static_assert(std::constructible_from<CSSTREAM,
-                                        std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
+                                        const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
                                         std::ios_base::openmode,
-                                        test_allocator<CharT>>);
+                                        const test_allocator<CharT>>);
   static_assert(test_convertible<CSSTREAM,
                                  const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
                                  std::ios_base::openmode,
@@ -87,7 +88,35 @@ void test_sfinae() {
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
 
-  // String-view-like
+  // nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+  // const nasty_char*
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
+  static_assert(
+      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+  // `CustomStringView`
+  static_assert(std::constructible_from<SSTREAM,
+                                        const CustomStringView<CharT>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
+  static_assert(
+      test_convertible<SSTREAM, const CustomStringView<CharT>, std::ios_base::openmode, const test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const CustomStringView<CharT, constexpr_char_traits<CharT>>,
+                                        std::ios_base::openmode,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM,
+                                 const CustomStringView<CharT, constexpr_char_traits<CharT>>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
+
+  // Non-`string-view-like`
   static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
 
@@ -95,11 +124,11 @@ void test_sfinae() {
       !std::constructible_from<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>());
 
-  // Mode
-  static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, SomeObject, const NonAllocator>);
-  static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, SomeObject, const NonAllocator>());
+  // Non-mode
+  static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, NonMode, const NonAllocator>);
+  static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, NonMode, const NonAllocator>());
 
-  // Allocator
+  // Non-allocator
   static_assert(!std::constructible_from<SSTREAM,
                                          const std::basic_string_view<CharT>,
                                          std::ios_base::openmode,
@@ -138,6 +167,13 @@ static void test() {
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
+  // CustomStringView<CharT>
+  {
+    const CustomStringView<CharT> ccsv{CS("zmt")};
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(ccsv, std::ios_base::binary, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
 }
 
 int main(int, char**) {
diff --git a/libcxx/test/std/input.output/string.streams/types.h b/libcxx/test/std/input.output/string.streams/types.h
new file mode 100644
index 00000000000000..ad1e2618a64075
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/types.h
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H
+
+#include <string_view>
+#include <concepts>
+
+#include "test_macros.h"
+
+template <typename CharT, class Traits = std::char_traits<CharT>>
+class CustomStringView {
+public:
+  explicit CustomStringView(const CharT* cs) : cs_{cs} {}
+
+  template <std::same_as<std::basic_string_view<CharT, Traits>> T>
+  operator T() const {
+    return std::basic_string_view<CharT, Traits>(cs_);
+  }
+
+private:
+  const CharT* cs_;
+};
+
+static_assert(std::constructible_from<std::basic_string_view<char>, CustomStringView<char>>);
+static_assert(std::convertible_to<CustomStringView<char>, std::basic_string_view<char>>);
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(std::convertible_to<CustomStringView<wchar_t>, std::basic_string_view<wchar_t>>);
+#endif
+
+struct SomeObject {};
+
+struct NonMode {};
+
+struct NonAllocator {};
+
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H

>From 091bc725bd4b17a141383a886d0293149467c650 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Fri, 16 Feb 2024 11:54:49 +0200
Subject: [PATCH 12/17] WIP: Added `ConstConvertibleStringView`

---
 .../string_view.mode.alloc.pass.cpp           | 57 ++++++++++++++---
 .../std/input.output/string.streams/types.h   | 61 ++++++++++++++++---
 2 files changed, 100 insertions(+), 18 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 011367a5fb5969..7314627914d051 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -99,23 +99,62 @@ void test_sfinae() {
   static_assert(
       test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
 
-  // `CustomStringView`
+  // ConstConvertibleStringView<CharT>
   static_assert(std::constructible_from<SSTREAM,
-                                        const CustomStringView<CharT>,
+                                        const ConstConvertibleStringView<CharT>,
                                         std::ios_base::openmode,
                                         const test_allocator<CharT>>);
-  static_assert(
-      test_convertible<SSTREAM, const CustomStringView<CharT>, std::ios_base::openmode, const test_allocator<CharT>>());
+  static_assert(test_convertible<SSTREAM,
+                                 const ConstConvertibleStringView<CharT>,
+                                 std::ios_base::openmode,
+                                 const test_allocator<CharT>>());
 
   static_assert(std::constructible_from<CSSTREAM,
-                                        const CustomStringView<CharT, constexpr_char_traits<CharT>>,
+                                        const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                         std::ios_base::openmode,
                                         const test_allocator<CharT>>);
   static_assert(test_convertible<CSSTREAM,
-                                 const CustomStringView<CharT, constexpr_char_traits<CharT>>,
+                                 const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
 
+  // NonConstConvertibleStringView<CharT>
+  static_assert(!std::constructible_from<SSTREAM,
+                                         NonConstConvertibleStringView<CharT>,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM,
+                                  NonConstConvertibleStringView<CharT>,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<SSTREAM,
+                                         const NonConstConvertibleStringView<CharT>,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM,
+                                  const NonConstConvertibleStringView<CharT>,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         std::ios_base::openmode,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                  std::ios_base::openmode,
+                                  const test_allocator<CharT>>());
+
   // Non-`string-view-like`
   static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
@@ -167,10 +206,10 @@ static void test() {
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
-  // CustomStringView<CharT>
+  // ConstConvertibleStringView<CharT>
   {
-    const CustomStringView<CharT> ccsv{CS("zmt")};
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(ccsv, std::ios_base::binary, ca);
+    const ConstConvertibleStringView<CharT> sv{CS("zmt")};
+    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(sv, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
diff --git a/libcxx/test/std/input.output/string.streams/types.h b/libcxx/test/std/input.output/string.streams/types.h
index ad1e2618a64075..14b489abfad4b7 100644
--- a/libcxx/test/std/input.output/string.streams/types.h
+++ b/libcxx/test/std/input.output/string.streams/types.h
@@ -15,24 +15,67 @@
 #include "test_macros.h"
 
 template <typename CharT, class Traits = std::char_traits<CharT>>
-class CustomStringView {
+class ConstConvertibleStringView {
 public:
-  explicit CustomStringView(const CharT* cs) : cs_{cs} {}
+  explicit ConstConvertibleStringView(const CharT* cs) : cs_{cs} {}
 
-  template <std::same_as<std::basic_string_view<CharT, Traits>> T>
-  operator T() const {
-    return std::basic_string_view<CharT, Traits>(cs_);
-  }
+  operator std::basic_string_view<CharT, Traits>() = delete;
+
+  // template <std::same_as<std::basic_string_view<CharT, Traits>> T>
+  // operator T() const {
+  //   return std::basic_string_view<CharT, Traits>(cs_);
+  // }
+
+  operator std::basic_string_view<CharT, Traits>() const { return std::basic_string_view<CharT, Traits>(cs_); }
+
+private:
+  const CharT* cs_;
+};
+
+static_assert(!std::constructible_from<std::basic_string_view<char>, ConstConvertibleStringView<char>>);
+static_assert(!std::convertible_to<ConstConvertibleStringView<char>, std::basic_string_view<char>>);
+
+static_assert(std::constructible_from<std::basic_string_view<char>, const ConstConvertibleStringView<char>>);
+static_assert(std::convertible_to<const ConstConvertibleStringView<char>, std::basic_string_view<char>>);
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+static_assert(!std::constructible_from<std::basic_string_view<wchar_t>, ConstConvertibleStringView<wchar_t>>);
+static_assert(!std::convertible_to<ConstConvertibleStringView<wchar_t>, std::basic_string_view<wchar_t>>);
+
+static_assert(std::constructible_from<std::basic_string_view<wchar_t>, const ConstConvertibleStringView<wchar_t>>);
+static_assert(std::convertible_to<const ConstConvertibleStringView<wchar_t>, std::basic_string_view<wchar_t>>);
+#endif
+
+template <typename CharT, class Traits = std::char_traits<CharT>>
+class NonConstConvertibleStringView {
+public:
+  explicit NonConstConvertibleStringView(const CharT* cs) : cs_{cs} {}
+
+  // template <std::same_as<std::basic_string_view<CharT, Traits>> T>
+  // operator T() {
+  //   return std::basic_string_view<CharT, Traits>(cs_);
+  // }
+
+  operator std::basic_string_view<CharT, Traits>() { return std::basic_string_view<CharT, Traits>(cs_); }
+
+  operator std::basic_string_view<CharT, Traits>() const = delete;
 
 private:
   const CharT* cs_;
 };
 
-static_assert(std::constructible_from<std::basic_string_view<char>, CustomStringView<char>>);
-static_assert(std::convertible_to<CustomStringView<char>, std::basic_string_view<char>>);
+static_assert(std::constructible_from<std::basic_string_view<char>, NonConstConvertibleStringView<char>>);
+static_assert(std::convertible_to<NonConstConvertibleStringView<char>, std::basic_string_view<char>>);
+
+static_assert(!std::constructible_from<std::basic_string_view<char>, const NonConstConvertibleStringView<char>>);
+static_assert(!std::convertible_to<const NonConstConvertibleStringView<char>, std::basic_string_view<char>>);
 
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(std::convertible_to<CustomStringView<wchar_t>, std::basic_string_view<wchar_t>>);
+static_assert(std::constructible_from<std::basic_string_view<wchar_t>, NonConstConvertibleStringView<wchar_t>>);
+static_assert(std::convertible_to<NonConstConvertibleStringView<wchar_t>, std::basic_string_view<wchar_t>>);
+
+static_assert(!std::constructible_from<std::basic_string_view<wchar_t>, const NonConstConvertibleStringView<wchar_t>>);
+static_assert(!std::convertible_to<const NonConstConvertibleStringView<wchar_t>, std::basic_string_view<wchar_t>>);
 #endif
 
 struct SomeObject {};

>From 3f04eb01d441a1229c9675b97b10d90d20e40975 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 08:39:56 +0200
Subject: [PATCH 13/17] Updated: `string_view.alloc.pass`

---
 .../string_view.alloc.pass.cpp                | 131 +++++++++++++-----
 .../string_view.mode.alloc.pass.cpp           |   2 +-
 2 files changed, 95 insertions(+), 38 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
index 92ec33f6a0d61b..2a68299c96477b 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
@@ -22,55 +22,103 @@
 #include <string>
 #include <string_view>
 
+#include "constexpr_char_traits.h"
 #include "make_string.h"
+#include "nasty_string.h"
 #include "test_allocator.h"
 #include "test_convertible.h"
 #include "test_macros.h"
 
+#include "../../types.h"
+
 template <typename CharT>
 void test_sfinae() {
-  struct SomeObject {};
-  struct NonAllocator {};
+  using SSTREAM  = SSTREAM;
+  using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
+
+  // `CharT*`
+  static_assert(std::constructible_from<SSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, CharT*, const test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, CharT*, const test_allocator<CharT>>());
 
   // `const CharT*`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        const CharT*,
-                                        const test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 const CharT*,
-                                 const test_allocator<CharT>>());
+  static_assert(std::constructible_from<SSTREAM, const CharT*, const test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, const CharT*, const test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM, const CharT*, const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, const CharT*, const test_allocator<CharT>>());
+
   // `std::basic_string_view<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        const std::basic_string_view<CharT>,
-                                        const test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 std::basic_string_view<CharT>,
-                                 test_allocator<CharT>>());
+  static_assert(std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, std::basic_string_view<CharT>, test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, std::basic_string_view<CharT>, test_allocator<CharT>>());
+
   // `std::basic_string<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        const std::basic_string<CharT>,
+  static_assert(std::constructible_from<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
+  static_assert(test_convertible<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
+  static_assert(std::constructible_from<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
+
+  // nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, nasty_char*, const test_allocator<nasty_char>>());
+
+  // const nasty_char*
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, const nasty_char*, const test_allocator<nasty_char>>());
+
+  // ConstConvertibleStringView<CharT>
+  static_assert(std::constructible_from<SSTREAM,
+                                        const ConstConvertibleStringView<CharT>,
+
                                         const test_allocator<CharT>>);
-  static_assert(test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                 const std::basic_string<CharT>,
+  static_assert(test_convertible<SSTREAM,
+                                 const ConstConvertibleStringView<CharT>,
+
+                                 const test_allocator<CharT>>());
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                        const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM,
+                                 const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                  const test_allocator<CharT>>());
 
-  // String-view-like
+  // NonConstConvertibleStringView<CharT>
+  static_assert(!std::constructible_from<SSTREAM, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
+
   static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const SomeObject,
-                               const test_allocator<CharT>>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject,
+      !std::constructible_from<SSTREAM, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
+
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                   const test_allocator<CharT>>());
 
-  // Allocator
-  static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const std::basic_string_view<CharT>,
-                               const NonAllocator>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const std::basic_string_view<CharT>,
-                                  const NonAllocator>());
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         const test_allocator<CharT>>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                  const test_allocator<CharT>>());
+
+  // Non-`string-view-like`
+  static_assert(!std::constructible_from<SSTREAM, const SomeObject, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, const SomeObject, const test_allocator<CharT>>());
+
+  // Non-allocator
+  static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, const NonAllocator>);
+  static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, const NonAllocator>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -79,25 +127,34 @@ void test_sfinae() {
 
 template <class CharT>
 static void test() {
+  using SSTREAM = SSTREAM;
+
   const test_allocator<CharT> ca;
 
   // const CharT*
   {
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+    SSTREAM ss(CS("zmt"), ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string_view<CharT>
   {
-    const auto csv = SV("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+    const std::basic_string_view<CharT> csv = SV("zmt");
+    SSTREAM ss(csv, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
   // std::basic_string<CharT>
   {
-    const auto cs = ST("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+    const std::basic_string<CharT> cs = ST("zmt");
+    SSTREAM ss(cs, ca);
+    assert(ss.str() == CS("zmt"));
+    assert(ss.rdbuf()->get_allocator() == ca);
+  }
+  // ConstConvertibleStringView<CharT>
+  {
+    const ConstConvertibleStringView<CharT> sv{CS("zmt")};
+    SSTREAM ss(sv, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 7314627914d051..7eb671b8ac49c9 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -209,7 +209,7 @@ static void test() {
   // ConstConvertibleStringView<CharT>
   {
     const ConstConvertibleStringView<CharT> sv{CS("zmt")};
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(sv, std::ios_base::binary, ca);
+    SSTREAM ss(sv, std::ios_base::binary, ca);
     assert(ss.str() == CS("zmt"));
     assert(ss.rdbuf()->get_allocator() == ca);
   }

>From 5e9f49e3694e6f55f73b4611a95fe2c4d2ec3e88 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 10:25:18 +0200
Subject: [PATCH 14/17] Updated: `str.string_view.pass`

---
 .../string_view.alloc.pass.cpp                |  35 ++---
 .../string_view.mode.alloc.pass.cpp           |  22 +--
 .../string_view.mode.pass.cpp                 | 141 +++++++++++++-----
 .../str.string_view.pass.cpp                  |  37 ++++-
 .../string_view.mode.pass.cpp                 |   2 +-
 .../stringbuf.cons/string_view.mode.pass.cpp  |   2 +-
 .../string_view.mode.pass.cpp                 |   2 +-
 7 files changed, 168 insertions(+), 73 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
index 2a68299c96477b..c55e06e6f8617b 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
@@ -33,14 +33,14 @@
 
 template <typename CharT>
 void test_sfinae() {
-  using SSTREAM  = SSTREAM;
+  using SSTREAM  = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
   using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
 
   // `CharT*`
-  static_assert(std::constructible_from<SSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(std::constructible_from<SSTREAM, CharT*, const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM, CharT*, const test_allocator<CharT>>());
 
-  static_assert(std::constructible_from<CSSTREAM, CharT*, test_allocator<CharT>>);
+  static_assert(std::constructible_from<CSSTREAM, CharT*, const test_allocator<CharT>>);
   static_assert(test_convertible<CSSTREAM, CharT*, const test_allocator<CharT>>());
 
   // `const CharT*`
@@ -54,24 +54,15 @@ void test_sfinae() {
   static_assert(std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM, std::basic_string_view<CharT>, test_allocator<CharT>>());
 
-  static_assert(std::constructible_from<CSSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
-  static_assert(test_convertible<CSSTREAM, std::basic_string_view<CharT>, test_allocator<CharT>>());
+  // static_assert(std::constructible_from<CSSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
+  // static_assert(test_convertible<CSSTREAM, std::basic_string_view<CharT>, const test_allocator<CharT>>());
 
   // `std::basic_string<CharT>`
   static_assert(std::constructible_from<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
-  static_assert(std::constructible_from<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
-  static_assert(test_convertible<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
 
-  // nasty_char*
-  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
-  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
-  static_assert(test_convertible<NSSTREAM, nasty_char*, const test_allocator<nasty_char>>());
-
-  // const nasty_char*
-  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
-  static_assert(test_convertible<NSSTREAM, const nasty_char*, const test_allocator<nasty_char>>());
+  // static_assert(std::constructible_from<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
+  // static_assert(test_convertible<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
 
   // ConstConvertibleStringView<CharT>
   static_assert(std::constructible_from<SSTREAM,
@@ -112,6 +103,16 @@ void test_sfinae() {
                                   const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                   const test_allocator<CharT>>());
 
+  // nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, nasty_char*, const test_allocator<nasty_char>>());
+
+  // const nasty_char*
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, const nasty_char*, const test_allocator<nasty_char>>());
+
   // Non-`string-view-like`
   static_assert(!std::constructible_from<SSTREAM, const SomeObject, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const SomeObject, const test_allocator<CharT>>());
@@ -127,7 +128,7 @@ void test_sfinae() {
 
 template <class CharT>
 static void test() {
-  using SSTREAM = SSTREAM;
+  using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
 
   const test_allocator<CharT> ca;
 
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 7eb671b8ac49c9..3a276e3c8ca090 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -88,17 +88,6 @@ void test_sfinae() {
                                  std::ios_base::openmode,
                                  const test_allocator<CharT>>());
 
-  // nasty_char*
-  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
-  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
-  static_assert(test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
-
-  // const nasty_char*
-  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
-  static_assert(
-      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
-
   // ConstConvertibleStringView<CharT>
   static_assert(std::constructible_from<SSTREAM,
                                         const ConstConvertibleStringView<CharT>,
@@ -155,6 +144,17 @@ void test_sfinae() {
                                   std::ios_base::openmode,
                                   const test_allocator<CharT>>());
 
+  // nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+  // const nasty_char*
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
+  static_assert(
+      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
   // Non-`string-view-like`
   static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
index 46e4d864cc1220..da5e0570f3b391 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
@@ -14,7 +14,7 @@
 // class basic_stringstream
 
 // template<class T>
-//   basic_istringstream(const T& t, ios_base::openmode which);
+//   explicit basic_istringstream(const T& t, ios_base::openmode which);
 
 #include <cassert>
 #include <concepts>
@@ -22,61 +22,115 @@
 #include <string>
 #include <string_view>
 
+#include "constexpr_char_traits.h"
 #include "make_string.h"
+#include "nasty_string.h"
 #include "test_allocator.h"
 #include "test_convertible.h"
 #include "test_macros.h"
 
+#include "../../types.h"
+
 template <typename CharT>
 void test_sfinae() {
-  struct SomeObject {};
+  using SSTREAM  = std::basic_istringstream<CharT, std::char_traits<CharT>>;
+  using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>>;
+
+  // `CharT*`
+
+  static_assert(std::constructible_from<SSTREAM, CharT*, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, CharT*, std::ios_base::openmode>());
+
+  static_assert(std::constructible_from<CSSTREAM, CharT*, std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM, CharT*, std::ios_base::openmode>());
 
   // `const CharT*`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>>,
-                                        const CharT*,
-                                        std::ios_base::openmode>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
-                                  const CharT*,
-                                  std::ios_base::openmode>());
+  static_assert(std::constructible_from<SSTREAM, const CharT*, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const CharT*, std::ios_base::openmode>());
+
+  static_assert(std::constructible_from<CSSTREAM, const CharT*, std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM, const CharT*, std::ios_base::openmode, std::ios_base::openmode>());
+
   // `std::basic_string_view<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+  static_assert(std::constructible_from<SSTREAM,
                                         const std::basic_string_view<CharT, std::char_traits<CharT>>,
                                         std::ios_base::openmode>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>>,
+  static_assert(!test_convertible<SSTREAM,
                                   const std::basic_string_view<CharT, std::char_traits<CharT>>,
                                   std::ios_base::openmode>());
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+
   // `std::basic_string<CharT>`
-  static_assert(std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                        const std::basic_string<CharT>,
+  static_assert(std::constructible_from<SSTREAM, const std::basic_string<CharT>, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const std::basic_string<CharT>, std::ios_base::openmode>());
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const std::basic_string<CharT, constexpr_char_traits<CharT>>,
                                         std::ios_base::openmode>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const std::basic_string<CharT>,
+  static_assert(!test_convertible<CSSTREAM,
+                                  const std::basic_string<CharT, constexpr_char_traits<CharT>>,
                                   std::ios_base::openmode>());
 
-  // String-view-like
-  static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const int,
-                               std::ios_base::openmode>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const int,
+  // ConstConvertibleStringView<CharT>
+  static_assert(std::constructible_from<SSTREAM, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>());
+
+  static_assert(std::constructible_from<CSSTREAM,
+                                        const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                        std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                   std::ios_base::openmode>());
-  static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const SomeObject,
-                               std::ios_base::openmode>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const SomeObject,
+
+  // NonConstConvertibleStringView<CharT>
+  static_assert(!std::constructible_from<SSTREAM, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
+
+  static_assert(!std::constructible_from<SSTREAM, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
+
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
                                   std::ios_base::openmode>());
 
-  // Mode
+  static_assert(!std::constructible_from<CSSTREAM,
+                                         const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                         std::ios_base::openmode>);
+  static_assert(!test_convertible<CSSTREAM,
+                                  const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
+                                  std::ios_base::openmode>());
+
+  //  nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
+  static_assert(test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+  // const nasty_char*
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
   static_assert(
-      !std::constructible_from<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                               const std::basic_string_view<CharT>,
-                               const SomeObject>);
-  static_assert(!test_convertible<std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
-                                  const std::basic_string_view<CharT>,
-                                  const SomeObject>());
+      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+  // String-view-like
+  static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode>());
+  static_assert(!std::constructible_from<SSTREAM, const SomeObject, std::ios_base::openmode>);
+  static_assert(!test_convertible<SSTREAM, const SomeObject, std::ios_base::openmode>());
+
+  // Non-mode
+  static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, const SomeObject>);
+  static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, const SomeObject>());
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -85,22 +139,29 @@ void test_sfinae() {
 
 template <class CharT>
 static void test() {
+  using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>>;
+
   // const CharT*
   {
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
-        CS("zmt"), std::ios_base::binary);
+    SSTREAM ss(CS("zmt"), std::ios_base::binary);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string_view<CharT>
   {
-    const auto csv = SV("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, std::ios_base::binary);
+    const std::basic_string_view<CharT> csv = SV("zmt");
+    SSTREAM ss(csv, std::ios_base::binary);
     assert(ss.str() == CS("zmt"));
   }
   // std::basic_string<CharT>
   {
-    const auto cs = ST("zmt");
-    std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, std::ios_base::binary);
+    const std::basic_string<CharT> cs = ST("zmt");
+    SSTREAM ss(cs, std::ios_base::binary);
+    assert(ss.str() == CS("zmt"));
+  }
+  // ConstConvertibleStringView<CharT>
+  {
+    const ConstConvertibleStringView<CharT> sv{CS("zmt")};
+    SSTREAM ss(sv, std::ios_base::binary);
     assert(ss.str() == CS("zmt"));
   }
 }
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
index a1c0d7e9f5b5bf..f19007f61c6465 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -21,9 +21,14 @@
 #include <string>
 #include <string_view>
 
+#include "constexpr_char_traits.h"
 #include "make_string.h"
+#include "nasty_string.h"
+#include "test_allocator.h"
 #include "test_macros.h"
 
+#include "../../types.h"
+
 template <typename S, typename T>
 concept HasStr = requires(S s, const T& sv) {
   { s.str(sv) };
@@ -31,17 +36,34 @@ concept HasStr = requires(S s, const T& sv) {
 
 template <typename CharT>
 void test_sfinae() {
-  struct SomeObject {};
+  using SSTREAM  = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+  using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
 
-  static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
   static_assert(HasStr<std::basic_istringstream<CharT>, CharT*>);
+  static_assert(HasStr<CSSTREAM, CharT*>);
+
+  static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
+  static_assert(HasStr<CSSTREAM, const CharT*>);
+
   static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
+  static_assert(HasStr<CSSTREAM, std::basic_string_view<CharT, constexpr_char_traits<CharT>>>);
+
   static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
+  static_assert(HasStr<CSSTREAM, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
+
+  using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+  static_assert(HasStr<NSSTREAM, nasty_char*>);
+  static_assert(HasStr<NSSTREAM, const nasty_char*>);
+  
+  static_assert(HasStr<std::basic_istringstream<CharT>, ConstConvertibleStringView<CharT>>);
+  static_assert(HasStr<CSSTREAM, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
 
   static_assert(!HasStr<std::basic_istringstream<CharT>, CharT>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, int>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, SomeObject>);
   static_assert(!HasStr<std::basic_istringstream<CharT>, std::nullptr_t>);
+  static_assert(!HasStr<std::basic_istringstream<CharT>, NonConstConvertibleStringView<CharT>>);
 }
 
 #define CS(S) MAKE_CSTRING(CharT, S)
@@ -52,12 +74,23 @@ template <typename CharT>
 void test() {
   std::basic_istringstream<CharT> ss;
   assert(ss.str().empty());
+
+  // const CharT*
   ss.str(CS("ba"));
   assert(ss.str() == CS("ba"));
+
+  // std::basic_string_view<CharT>
   ss.str(SV("ma"));
   assert(ss.str() == CS("ma"));
+
+  // std::basic_string<CharT>
   ss.str(ST("zmt"));
   assert(ss.str() == CS("zmt"));
+
+  // ConstConvertibleStringView<CharT>
+  ss.str(ConstConvertibleStringView<CharT>{CS("da")});
+  assert(ss.str() == CS("da"));
+
   const std::basic_string<CharT> s;
   ss.str(s);
   assert(ss.str().empty());
diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
index 7a87f1bfc73b64..a84198e24381a7 100644
--- a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string_view.mode.pass.cpp
@@ -14,7 +14,7 @@
 // class basic_stringstream
 
 // template<class T>
-//   basic_ostringstream(const T& t, ios_base::openmode which);
+//   explicit basic_ostringstream(const T& t, ios_base::openmode which);
 
 #include <cassert>
 #include <concepts>
diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
index 893a27befb794a..b7553214523c6e 100644
--- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string_view.mode.pass.cpp
@@ -14,7 +14,7 @@
 // class basic_stringstream
 
 // template<class T>
-//   basic_stringbuf(const T& t, ios_base::openmode which);
+//   explicit basic_stringbuf(const T& t, ios_base::openmode which);
 
 #include <cassert>
 #include <concepts>
diff --git a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
index e2ad1d447a7e27..cc8be6f0c8dc12 100644
--- a/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string_view.mode.pass.cpp
@@ -14,7 +14,7 @@
 // class basic_stringstream
 
 // template<class T>
-//   basic_stringstream(const T& t, ios_base::openmode which);
+//   explicit basic_stringstream(const T& t, ios_base::openmode which);
 
 #include <cassert>
 #include <concepts>

>From 10286b216b12f96d7f29b25a27036a73a7dadcb9 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 10:31:38 +0200
Subject: [PATCH 15/17] Fix formatting

---
 .../istringstream.members/str.string_view.pass.cpp              | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
index f19007f61c6465..013bb3d72d5829 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.string_view.pass.cpp
@@ -55,7 +55,7 @@ void test_sfinae() {
 
   static_assert(HasStr<NSSTREAM, nasty_char*>);
   static_assert(HasStr<NSSTREAM, const nasty_char*>);
-  
+
   static_assert(HasStr<std::basic_istringstream<CharT>, ConstConvertibleStringView<CharT>>);
   static_assert(HasStr<CSSTREAM, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
 

>From dc81b244a4b13735af3694184c0093fc39641fb3 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 10:47:55 +0200
Subject: [PATCH 16/17] Fixes

---
 .../istringstream.cons/string_view.mode.alloc.pass.cpp   | 6 +++---
 .../istringstream.cons/string_view.mode.pass.cpp         | 9 +++------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
index 3a276e3c8ca090..95fc3c565bcc58 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.alloc.pass.cpp
@@ -156,13 +156,13 @@ void test_sfinae() {
       test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
 
   // Non-`string-view-like`
-  static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
-  static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
-
   static_assert(
       !std::constructible_from<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>);
   static_assert(!test_convertible<SSTREAM, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>());
 
+  static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>);
+  static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode, const test_allocator<CharT>>());
+
   // Non-mode
   static_assert(!std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, NonMode, const NonAllocator>);
   static_assert(!test_convertible<SSTREAM, const std::basic_string_view<CharT>, NonMode, const NonAllocator>());
diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
index da5e0570f3b391..bc294fd94155fc 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.mode.pass.cpp
@@ -113,18 +113,15 @@ void test_sfinae() {
   using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
 
   static_assert(std::constructible_from<NSSTREAM, nasty_char*, test_allocator<nasty_char>>);
-  static_assert(test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+  static_assert(!test_convertible<NSSTREAM, nasty_char*, std::ios_base::openmode>());
 
   // const nasty_char*
   using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
 
   static_assert(std::constructible_from<NSSTREAM, const nasty_char*, test_allocator<nasty_char>>);
-  static_assert(
-      test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+  static_assert(!test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode>());
 
-  // String-view-like
-  static_assert(!std::constructible_from<SSTREAM, const int, std::ios_base::openmode>);
-  static_assert(!test_convertible<SSTREAM, const int, std::ios_base::openmode>());
+  // Non-`string-view-like`
   static_assert(!std::constructible_from<SSTREAM, const SomeObject, std::ios_base::openmode>);
   static_assert(!test_convertible<SSTREAM, const SomeObject, std::ios_base::openmode>());
 

>From 276855cce1196041690da4e9013186dc403ad465 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 10:52:05 +0200
Subject: [PATCH 17/17] Fixes

---
 .../istringstream.cons/string_view.alloc.pass.cpp         | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
index c55e06e6f8617b..3494bdb3b8d213 100644
--- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
+++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string_view.alloc.pass.cpp
@@ -54,15 +54,15 @@ void test_sfinae() {
   static_assert(std::constructible_from<SSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM, std::basic_string_view<CharT>, test_allocator<CharT>>());
 
-  // static_assert(std::constructible_from<CSSTREAM, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
-  // static_assert(test_convertible<CSSTREAM, std::basic_string_view<CharT>, const test_allocator<CharT>>());
+  static_assert(std::constructible_from<CSSTREAM, const std::basic_string_view<CharT, constexpr_char_traits<CharT>>, const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, std::basic_string_view<CharT, constexpr_char_traits<CharT>>, const test_allocator<CharT>>());
 
   // `std::basic_string<CharT>`
   static_assert(std::constructible_from<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
   static_assert(test_convertible<SSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
 
-  // static_assert(std::constructible_from<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>);
-  // static_assert(test_convertible<CSSTREAM, const std::basic_string<CharT>, const test_allocator<CharT>>());
+  static_assert(std::constructible_from<CSSTREAM, const std::basic_string<CharT, constexpr_char_traits<CharT>>, const test_allocator<CharT>>);
+  static_assert(test_convertible<CSSTREAM, const std::basic_string<CharT, constexpr_char_traits<CharT>>, const test_allocator<CharT>>());
 
   // ConstConvertibleStringView<CharT>
   static_assert(std::constructible_from<SSTREAM,



More information about the libcxx-commits mailing list