[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 Mar 3 08:25:57 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/31] [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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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/31] 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,
>From ed320fddd2a237f1b41762bd5ca6e38707eaf5f5 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 10:53:53 +0200
Subject: [PATCH 18/31] Fixes
---
.../string_view.alloc.pass.cpp | 26 ++++++++++---------
1 file changed, 14 insertions(+), 12 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 3494bdb3b8d213..4f03b49c2b3b54 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,26 +54,28 @@ 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, 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>>());
+ 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, 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,
- const ConstConvertibleStringView<CharT>,
-
+ static_assert(std::constructible_from<CSSTREAM,
+ const std::basic_string<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(test_convertible<SSTREAM,
- const ConstConvertibleStringView<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, const ConstConvertibleStringView<CharT>, const test_allocator<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>>);
>From 6cd0d59a69cb5d986db80eccc29f2e301e9ce35c Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 11:49:18 +0200
Subject: [PATCH 19/31] Fix
---
.../std/input.output/string.streams/concepts.h | 17 +++++++++++++++++
.../string_view.alloc.pass.cpp | 2 +-
.../str.string_view.pass.cpp | 12 ++++--------
.../std/input.output/string.streams/types.h | 12 ------------
4 files changed, 22 insertions(+), 21 deletions(-)
create mode 100644 libcxx/test/std/input.output/string.streams/concepts.h
diff --git a/libcxx/test/std/input.output/string.streams/concepts.h b/libcxx/test/std/input.output/string.streams/concepts.h
new file mode 100644
index 00000000000000..9917e968877bad
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/concepts.h
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_CONCEPTS_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
+
+template <typename S, typename T>
+concept HasStr = requires(S s, const T& sv) {
+ { s.str(sv) };
+};
+
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
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 4f03b49c2b3b54..e21f414402c246 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
@@ -52,7 +52,7 @@ void test_sfinae() {
// `std::basic_string_view<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(test_convertible<SSTREAM, 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>>,
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 013bb3d72d5829..7efdde55b2232e 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
@@ -27,13 +27,9 @@
#include "test_allocator.h"
#include "test_macros.h"
+#include "../../concepts.h"
#include "../../types.h"
-template <typename S, typename T>
-concept HasStr = requires(S s, const T& sv) {
- { s.str(sv) };
-};
-
template <typename CharT>
void test_sfinae() {
using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
@@ -51,14 +47,14 @@ void test_sfinae() {
static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string<CharT>>);
static_assert(HasStr<CSSTREAM, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(HasStr<std::basic_istringstream<CharT>, ConstConvertibleStringView<CharT>>);
+ static_assert(HasStr<CSSTREAM, ConstConvertibleStringView<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>);
diff --git a/libcxx/test/std/input.output/string.streams/types.h b/libcxx/test/std/input.output/string.streams/types.h
index 14b489abfad4b7..671666b2251fdb 100644
--- a/libcxx/test/std/input.output/string.streams/types.h
+++ b/libcxx/test/std/input.output/string.streams/types.h
@@ -20,12 +20,6 @@ class ConstConvertibleStringView {
explicit ConstConvertibleStringView(const CharT* cs) : cs_{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:
@@ -51,13 +45,7 @@ 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:
>From 5d08266f7b2ebaf7a5f9beff366f2c7951ebc930 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 18 Feb 2024 11:56:39 +0200
Subject: [PATCH 20/31] Fix
---
.../str.string_view.pass.cpp | 21 ++++++++++---------
1 file changed, 11 insertions(+), 10 deletions(-)
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 7efdde55b2232e..472509a7fcbcd4 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
@@ -35,19 +35,19 @@ void test_sfinae() {
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>, CharT*>);
+ static_assert(HasStr<SSTREAM, CharT*>);
static_assert(HasStr<CSSTREAM, CharT*>);
- static_assert(HasStr<std::basic_istringstream<CharT>, const CharT*>);
+ static_assert(HasStr<SSTREAM, const CharT*>);
static_assert(HasStr<CSSTREAM, const CharT*>);
- static_assert(HasStr<std::basic_istringstream<CharT>, std::basic_string_view<CharT>>);
+ static_assert(HasStr<SSTREAM, 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<SSTREAM, std::basic_string<CharT>>);
static_assert(HasStr<CSSTREAM, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
- static_assert(HasStr<std::basic_istringstream<CharT>, ConstConvertibleStringView<CharT>>);
+ static_assert(HasStr<SSTREAM, ConstConvertibleStringView<CharT>>);
static_assert(HasStr<CSSTREAM, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
@@ -55,11 +55,12 @@ void test_sfinae() {
static_assert(HasStr<NSSTREAM, nasty_char*>);
static_assert(HasStr<NSSTREAM, const nasty_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>);
- static_assert(!HasStr<std::basic_istringstream<CharT>, NonConstConvertibleStringView<CharT>>);
+ static_assert(!HasStr<SSTREAM, CharT>);
+ static_assert(!HasStr<SSTREAM, int>);
+ static_assert(!HasStr<SSTREAM, SomeObject>);
+ static_assert(!HasStr<SSTREAM, std::nullptr_t>);
+ static_assert(!HasStr<SSTREAM, NonConstConvertibleStringView<CharT>>);
+ static_assert(!HasStr<CSSTREAM, NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
}
#define CS(S) MAKE_CSTRING(CharT, S)
>From 7e0587eabd17fefd1e7c839c8cb4476449a0fdb2 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 10:27:24 +0200
Subject: [PATCH 21/31] Fix ALLCAPS type names
---
.../input.output/string.streams/concepts.h | 2 +-
.../string_view.alloc.pass.cpp | 88 ++++++++---------
.../string_view.mode.alloc.pass.cpp | 96 +++++++++----------
.../string_view.mode.pass.cpp | 90 ++++++++---------
.../str.string_view.pass.cpp | 45 +++++----
5 files changed, 162 insertions(+), 159 deletions(-)
diff --git a/libcxx/test/std/input.output/string.streams/concepts.h b/libcxx/test/std/input.output/string.streams/concepts.h
index 9917e968877bad..d31a33b4c7e22d 100644
--- a/libcxx/test/std/input.output/string.streams/concepts.h
+++ b/libcxx/test/std/input.output/string.streams/concepts.h
@@ -10,7 +10,7 @@
#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
template <typename S, typename T>
-concept HasStr = requires(S s, const T& sv) {
+concept is_valid_argument_for_str_member = requires(S s, const T& sv) {
{ s.str(sv) };
};
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 e21f414402c246..7870c676ece694 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,95 +33,95 @@
template <typename CharT>
void test_sfinae() {
- 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>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+ using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
// `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<StrStream, CharT*, const test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, CharT*, const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM, CharT*, const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM, CharT*, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<CStrStream, CharT*, const test_allocator<CharT>>);
+ static_assert(test_convertible<CStrStream, CharT*, const test_allocator<CharT>>());
// `const 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<StrStream, const CharT*, const test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, 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>>());
+ static_assert(std::constructible_from<CStrStream, const CharT*, const test_allocator<CharT>>);
+ static_assert(test_convertible<CStrStream, const CharT*, const test_allocator<CharT>>());
// `std::basic_string_view<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>, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, std::basic_string_view<CharT>, const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
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<StrStream, const std::basic_string<CharT>, const test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, const std::basic_string<CharT>, const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>());
// ConstConvertibleStringView<CharT>
- static_assert(std::constructible_from<SSTREAM, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(test_convertible<SSTREAM, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>());
// 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<StrStream, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
static_assert(
- !std::constructible_from<SSTREAM, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(!test_convertible<SSTREAM, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
+ !std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+ static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
const test_allocator<CharT>>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
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>>;
+ using NStrStream = 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>>());
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, 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<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, 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>>());
+ static_assert(!std::constructible_from<StrStream, const SomeObject, const test_allocator<CharT>>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, const NonAllocator>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, const NonAllocator>());
}
#define CS(S) MAKE_CSTRING(CharT, S)
@@ -130,34 +130,34 @@ void test_sfinae() {
template <class CharT>
static void test() {
- using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
const test_allocator<CharT> ca;
// const CharT*
{
- SSTREAM ss(CS("zmt"), ca);
+ StrStream ss(CS("zmt"), 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");
- SSTREAM ss(csv, ca);
+ StrStream ss(csv, ca);
assert(ss.str() == CS("zmt"));
assert(ss.rdbuf()->get_allocator() == ca);
}
// std::basic_string<CharT>
{
const std::basic_string<CharT> cs = ST("zmt");
- SSTREAM ss(cs, ca);
+ StrStream 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);
+ StrStream 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 95fc3c565bcc58..e819fce56df49b 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
@@ -33,147 +33,147 @@
template <typename CharT>
void test_sfinae() {
- 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>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+ using CStrStream = 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*, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, CharT*, test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM, CharT*, test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<CStrStream, CharT*, test_allocator<CharT>>);
+ static_assert(test_convertible<CStrStream, CharT*, std::ios_base::openmode, const 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<StrStream, const CharT*, test_allocator<CharT>>);
+ static_assert(test_convertible<StrStream, 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>>());
+ static_assert(std::constructible_from<CStrStream, const CharT*, test_allocator<CharT>>);
+ static_assert(test_convertible<CStrStream, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
// `std::basic_string_view<CharT>`
- static_assert(std::constructible_from<SSTREAM,
+ static_assert(std::constructible_from<StrStream,
const std::basic_string_view<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<SSTREAM,
+ static_assert(test_convertible<StrStream,
const std::basic_string_view<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
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<SSTREAM,
+ static_assert(std::constructible_from<StrStream,
const std::basic_string<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<SSTREAM,
+ static_assert(test_convertible<StrStream,
const std::basic_string<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>());
// ConstConvertibleStringView<CharT>
- static_assert(std::constructible_from<SSTREAM,
+ static_assert(std::constructible_from<StrStream,
const ConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<SSTREAM,
+ static_assert(test_convertible<StrStream,
const ConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(test_convertible<CSSTREAM,
+ static_assert(test_convertible<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>());
// NonConstConvertibleStringView<CharT>
- static_assert(!std::constructible_from<SSTREAM,
+ static_assert(!std::constructible_from<StrStream,
NonConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(!test_convertible<SSTREAM,
+ static_assert(!test_convertible<StrStream,
NonConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(!std::constructible_from<SSTREAM,
+ static_assert(!std::constructible_from<StrStream,
const NonConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(!test_convertible<SSTREAM,
+ static_assert(!test_convertible<StrStream,
const NonConstConvertibleStringView<CharT>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode,
const test_allocator<CharT>>());
// nasty_char*
- using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+ using NStrStream = 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(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, 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(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
static_assert(
- test_convertible<NSSTREAM, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+ test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
// Non-`string-view-like`
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>>());
+ !std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>);
+ static_assert(!test_convertible<StrStream, 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>>());
+ static_assert(!std::constructible_from<StrStream, const int, std::ios_base::openmode, const test_allocator<CharT>>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, NonMode, const NonAllocator>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, NonMode, const NonAllocator>());
// Non-allocator
- static_assert(!std::constructible_from<SSTREAM,
+ static_assert(!std::constructible_from<StrStream,
const std::basic_string_view<CharT>,
std::ios_base::openmode,
const NonAllocator>);
static_assert(
- !test_convertible<SSTREAM, const std::basic_string_view<CharT>, std::ios_base::openmode, const NonAllocator>());
+ !test_convertible<StrStream, const std::basic_string_view<CharT>, std::ios_base::openmode, const NonAllocator>());
}
#define CS(S) MAKE_CSTRING(CharT, S)
@@ -182,34 +182,34 @@ void test_sfinae() {
template <class CharT>
static void test() {
- using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
const test_allocator<CharT> ca;
// const CharT*
{
- SSTREAM ss(CS("zmt"), std::ios_base::binary, ca);
+ StrStream 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");
- SSTREAM ss(csv, std::ios_base::binary, ca);
+ StrStream 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");
- SSTREAM ss(cs, std::ios_base::binary, ca);
+ StrStream ss(cs, std::ios_base::binary, ca);
assert(ss.str() == CS("zmt"));
assert(ss.rdbuf()->get_allocator() == ca);
}
// ConstConvertibleStringView<CharT>
{
const ConstConvertibleStringView<CharT> sv{CS("zmt")};
- SSTREAM ss(sv, std::ios_base::binary, ca);
+ StrStream 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/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 bc294fd94155fc..43ac976dbac86d 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
@@ -33,101 +33,101 @@
template <typename CharT>
void test_sfinae() {
- using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>>;
- using CSSTREAM = std::basic_istringstream<CharT, constexpr_char_traits<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>>;
+ using CStrStream = 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<StrStream, CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(std::constructible_from<CStrStream, CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<CStrStream, CharT*, std::ios_base::openmode>());
// `const CharT*`
- 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<StrStream, const CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(std::constructible_from<CStrStream, const CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<CStrStream, const CharT*, std::ios_base::openmode, std::ios_base::openmode>());
// `std::basic_string_view<CharT>`
- static_assert(std::constructible_from<SSTREAM,
+ static_assert(std::constructible_from<StrStream,
const std::basic_string_view<CharT, std::char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<SSTREAM,
+ static_assert(!test_convertible<StrStream,
const std::basic_string_view<CharT, std::char_traits<CharT>>,
std::ios_base::openmode>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>());
// `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<StrStream, const std::basic_string<CharT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string<CharT>, std::ios_base::openmode>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const std::basic_string<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>());
// 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<StrStream, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>());
- static_assert(std::constructible_from<CSSTREAM,
+ static_assert(std::constructible_from<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>());
// 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<StrStream, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>());
- static_assert(!std::constructible_from<CSSTREAM,
+ static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
std::ios_base::openmode>);
- static_assert(!test_convertible<CSSTREAM,
+ static_assert(!test_convertible<CStrStream,
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>>;
+ using NStrStream = 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>());
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
// const nasty_char*
- using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+ using NStrStream = 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>());
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, const nasty_char*, 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>());
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, const SomeObject>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, const SomeObject>());
}
#define CS(S) MAKE_CSTRING(CharT, S)
@@ -136,29 +136,29 @@ void test_sfinae() {
template <class CharT>
static void test() {
- using SSTREAM = std::basic_istringstream<CharT, std::char_traits<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>>;
// const CharT*
{
- SSTREAM ss(CS("zmt"), std::ios_base::binary);
+ StrStream ss(CS("zmt"), std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
// std::basic_string_view<CharT>
{
const std::basic_string_view<CharT> csv = SV("zmt");
- SSTREAM ss(csv, std::ios_base::binary);
+ StrStream ss(csv, std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
// std::basic_string<CharT>
{
const std::basic_string<CharT> cs = ST("zmt");
- SSTREAM ss(cs, std::ios_base::binary);
+ StrStream 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);
+ StrStream 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 472509a7fcbcd4..06726159140a1d 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
@@ -32,35 +32,38 @@
template <typename CharT>
void test_sfinae() {
- 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>>;
+ using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
+ using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
- static_assert(HasStr<SSTREAM, CharT*>);
- static_assert(HasStr<CSSTREAM, CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, CharT*>);
+ static_assert(is_valid_argument_for_str_member<CStrStream, CharT*>);
- static_assert(HasStr<SSTREAM, const CharT*>);
- static_assert(HasStr<CSSTREAM, const CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, const CharT*>);
+ static_assert(is_valid_argument_for_str_member<CStrStream, const CharT*>);
- static_assert(HasStr<SSTREAM, std::basic_string_view<CharT>>);
- static_assert(HasStr<CSSTREAM, std::basic_string_view<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string_view<CharT>>);
+ static_assert(
+ is_valid_argument_for_str_member<CStrStream, std::basic_string_view<CharT, constexpr_char_traits<CharT>>>);
- static_assert(HasStr<SSTREAM, std::basic_string<CharT>>);
- static_assert(HasStr<CSSTREAM, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string<CharT>>);
+ static_assert(is_valid_argument_for_str_member<CStrStream, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
- static_assert(HasStr<SSTREAM, ConstConvertibleStringView<CharT>>);
- static_assert(HasStr<CSSTREAM, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, ConstConvertibleStringView<CharT>>);
+ static_assert(
+ is_valid_argument_for_str_member<CStrStream, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
- using NSSTREAM = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+ using NStrStream = 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(is_valid_argument_for_str_member<NStrStream, nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<NStrStream, const nasty_char*>);
- static_assert(!HasStr<SSTREAM, CharT>);
- static_assert(!HasStr<SSTREAM, int>);
- static_assert(!HasStr<SSTREAM, SomeObject>);
- static_assert(!HasStr<SSTREAM, std::nullptr_t>);
- static_assert(!HasStr<SSTREAM, NonConstConvertibleStringView<CharT>>);
- static_assert(!HasStr<CSSTREAM, NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, CharT>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, int>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, SomeObject>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, std::nullptr_t>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, NonConstConvertibleStringView<CharT>>);
+ static_assert(!is_valid_argument_for_str_member<CStrStream,
+ NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
}
#define CS(S) MAKE_CSTRING(CharT, S)
>From b07d4512b3d4539e501880d961a52bb9b680a3dd Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 10:29:27 +0200
Subject: [PATCH 22/31] Fix formatting
---
.../istringstream.cons/string_view.alloc.pass.cpp | 6 ++++--
.../istringstream.cons/string_view.mode.pass.cpp | 3 ++-
2 files changed, 6 insertions(+), 3 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 7870c676ece694..4194231220e0cb 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
@@ -73,7 +73,8 @@ void test_sfinae() {
const test_allocator<CharT>>());
// ConstConvertibleStringView<CharT>
- static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
+ static_assert(
+ std::constructible_from<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
static_assert(std::constructible_from<CStrStream,
@@ -89,7 +90,8 @@ void test_sfinae() {
static_assert(
!std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
+ static_assert(
+ !test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
static_assert(!std::constructible_from<CStrStream,
const NonConstConvertibleStringView<CharT, constexpr_char_traits<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 43ac976dbac86d..1aad7e595a95ad 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
@@ -92,7 +92,8 @@ void test_sfinae() {
static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
- static_assert(!std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
+ static_assert(
+ !std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
static_assert(!std::constructible_from<CStrStream,
>From 955252b53c550cffeb311f841cf860b9bb682633 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 11:26:40 +0200
Subject: [PATCH 23/31] Updated: `basic_istringstream` - dynamic tests
---
.../string_view.alloc.pass.cpp | 43 ++++++++++---------
.../string_view.mode.alloc.pass.cpp | 42 +++++++++---------
.../string_view.mode.pass.cpp | 26 ++++++-----
.../str.string_view.pass.cpp | 25 ++++++-----
.../std/input.output/string.streams/macros.h | 18 ++++++++
5 files changed, 93 insertions(+), 61 deletions(-)
create mode 100644 libcxx/test/std/input.output/string.streams/macros.h
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 4194231220e0cb..e44ae062699133 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
@@ -18,17 +18,18 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#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 "../../macros.h"
#include "../../types.h"
template <typename CharT>
@@ -126,51 +127,53 @@ void test_sfinae() {
static_assert(!test_convertible<StrStream, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
-
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- StrStream ss(CS("zmt"), ca);
+ StrStream ss(CS("zmt"), allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string_view<CharT>
{
- const std::basic_string_view<CharT> csv = SV("zmt");
- StrStream ss(csv, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string<CharT>
{
- const std::basic_string<CharT> cs = ST("zmt");
- StrStream ss(cs, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// ConstConvertibleStringView<CharT>
{
- const ConstConvertibleStringView<CharT> sv{CS("zmt")};
- StrStream ss(sv, ca);
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
test_sfinae<char>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 e819fce56df49b..b96297efcfd051 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
@@ -23,12 +23,12 @@
#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 "../../macros.h"
#include "../../types.h"
template <typename CharT>
@@ -176,51 +176,53 @@ void test_sfinae() {
!test_convertible<StrStream, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
-
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- StrStream ss(CS("zmt"), std::ios_base::binary, ca);
+ StrStream ss(CS("zmt"), std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string_view<CharT>
{
- const std::basic_string_view<CharT> csv = SV("zmt");
- StrStream ss(csv, std::ios_base::binary, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string<CharT>
{
- const std::basic_string<CharT> cs = ST("zmt");
- StrStream ss(cs, std::ios_base::binary, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// ConstConvertibleStringView<CharT>
{
- const ConstConvertibleStringView<CharT> sv{CS("zmt")};
- StrStream ss(sv, std::ios_base::binary, ca);
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
test_sfinae<char>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 1aad7e595a95ad..03987d0a246c66 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
@@ -18,17 +18,18 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#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 "../../macros.h"
#include "../../types.h"
template <typename CharT>
@@ -37,7 +38,6 @@ void test_sfinae() {
using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>>;
// `CharT*`
-
static_assert(std::constructible_from<StrStream, CharT*, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, CharT*, std::ios_base::openmode>());
@@ -131,13 +131,11 @@ void test_sfinae() {
static_assert(!test_convertible<StrStream, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>>;
+ const AllocT allocator;
// const CharT*
{
@@ -146,19 +144,19 @@ static void test() {
}
// std::basic_string_view<CharT>
{
- const std::basic_string_view<CharT> csv = SV("zmt");
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
StrStream ss(csv, std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
// std::basic_string<CharT>
{
- const std::basic_string<CharT> cs = ST("zmt");
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
StrStream ss(cs, std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
// ConstConvertibleStringView<CharT>
{
- const ConstConvertibleStringView<CharT> sv{CS("zmt")};
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
StrStream ss(sv, std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
@@ -167,9 +165,15 @@ static void test() {
int main(int, char**) {
test_sfinae<char>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 06726159140a1d..b688d7afcef7c9 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
@@ -17,17 +17,18 @@
// void str(const T& t);
#include <cassert>
+#include <memory>
#include <sstream>
#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 "../../concepts.h"
+#include "../../macros.h"
#include "../../types.h"
template <typename CharT>
@@ -66,13 +67,11 @@ void test_sfinae() {
NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
}
-#define CS(S) MAKE_CSTRING(CharT, S)
-#define ST(S) MAKE_STRING(CharT, S)
-#define SV(S) MAKE_STRING_VIEW(CharT, S)
-
-template <typename CharT>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test() {
- std::basic_istringstream<CharT> ss;
+ AllocT allocator;
+
+ std::basic_istringstream<CharT, TraitsT, AllocT> ss( std::ios_base::in , allocator);
assert(ss.str().empty());
// const CharT*
@@ -84,14 +83,14 @@ void test() {
assert(ss.str() == CS("ma"));
// std::basic_string<CharT>
- ss.str(ST("zmt"));
+ ss.str(ST("zmt", allocator));
assert(ss.str() == CS("zmt"));
// ConstConvertibleStringView<CharT>
- ss.str(ConstConvertibleStringView<CharT>{CS("da")});
+ ss.str(ConstConvertibleStringView<CharT, TraitsT>{CS("da")});
assert(ss.str() == CS("da"));
- const std::basic_string<CharT> s;
+ const std::basic_string<CharT, TraitsT, AllocT> s(allocator);
ss.str(s);
assert(ss.str().empty());
}
@@ -99,9 +98,15 @@ void test() {
int main(int, char**) {
test_sfinae<char>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
#endif
return 0;
diff --git a/libcxx/test/std/input.output/string.streams/macros.h b/libcxx/test/std/input.output/string.streams/macros.h
new file mode 100644
index 00000000000000..964aea57100e79
--- /dev/null
+++ b/libcxx/test/std/input.output/string.streams/macros.h
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MACROS_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_MACROS_H
+
+#include "make_string.h"
+
+#define CS(S) MAKE_CSTRING(CharT, S)
+#define ST(S, a) std::basic_string<CharT, TraitsT, AllocT>(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S), a)
+#define SV(S) std::basic_string_view<CharT, TraitsT>(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S))
+
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_MACROS_H
>From cd13d559228460aa77972d2dd7bf8e13b99d7e9f Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 13:10:58 +0200
Subject: [PATCH 24/31] Updated: `basic_istringstream` tests
---
.../string_view.alloc.pass.cpp | 116 +++++--------
.../string_view.mode.alloc.pass.cpp | 163 +++++++-----------
.../string_view.mode.pass.cpp | 115 +++++-------
.../str.string_view.pass.cpp | 49 +++---
4 files changed, 169 insertions(+), 274 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 e44ae062699133..adf34aff631a26 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
@@ -32,99 +32,57 @@
#include "../../macros.h"
#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, nasty_char*, const AllocT>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, const nasty_char*, const AllocT>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
- using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
// `CharT*`
- static_assert(std::constructible_from<StrStream, CharT*, const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, CharT*, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream, CharT*, const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream, CharT*, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, const AllocT>());
// `const CharT*`
- static_assert(std::constructible_from<StrStream, const CharT*, const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, const CharT*, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream, const CharT*, const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream, const CharT*, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, const AllocT>());
// `std::basic_string_view<CharT>`
- static_assert(std::constructible_from<StrStream, const std::basic_string_view<CharT>, const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, std::basic_string_view<CharT>, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, std::basic_string_view<CharT, TraitsT>, const AllocT>());
// `std::basic_string<CharT>`
- static_assert(std::constructible_from<StrStream, const std::basic_string<CharT>, const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, const std::basic_string<CharT>, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>());
// ConstConvertibleStringView<CharT>
- static_assert(
- std::constructible_from<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
// NonConstConvertibleStringView<CharT>
- static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
-
- static_assert(
- !std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>);
- static_assert(
- !test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, const test_allocator<CharT>>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- const test_allocator<CharT>>());
+ static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
- // nasty_char*
- using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
- static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
- static_assert(test_convertible<NStrStream, nasty_char*, const test_allocator<nasty_char>>());
-
- // const nasty_char*
- static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
- static_assert(test_convertible<NStrStream, const nasty_char*, const test_allocator<nasty_char>>());
+ static_assert(!std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
// Non-`string-view-like`
- static_assert(!std::constructible_from<StrStream, const SomeObject, const test_allocator<CharT>>);
- static_assert(!test_convertible<StrStream, const SomeObject, const test_allocator<CharT>>());
+ static_assert(!std::constructible_from<StrStream, const SomeObject, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, const AllocT>());
// Non-allocator
- static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, const NonAllocator>);
- static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, const NonAllocator>());
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const NonAllocator>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, const NonAllocator>());
}
template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
@@ -163,13 +121,21 @@ void test() {
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
test<char, constexpr_char_traits<char>, std::allocator<char>>();
test<char, std::char_traits<char>, test_allocator<char>>();
test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
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 b96297efcfd051..b57cb26d17e111 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
@@ -18,6 +18,7 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
@@ -31,149 +32,101 @@
#include "../../macros.h"
#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(
+ test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
- using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
// `CharT*`
- static_assert(std::constructible_from<StrStream, CharT*, test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream, CharT*, test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream, CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, std::ios_base::openmode, const AllocT>());
// `const CharT*`
- static_assert(std::constructible_from<StrStream, const CharT*, test_allocator<CharT>>);
- static_assert(test_convertible<StrStream, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream, const CharT*, test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream, const CharT*, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, std::ios_base::openmode, const AllocT>());
// `std::basic_string_view<CharT>`
static_assert(std::constructible_from<StrStream,
- const std::basic_string_view<CharT>,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
+ const AllocT>);
static_assert(test_convertible<StrStream,
- const std::basic_string_view<CharT>,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
// `std::basic_string<CharT>`
static_assert(std::constructible_from<StrStream,
- const std::basic_string<CharT>,
+ const std::basic_string<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(test_convertible<StrStream,
- const std::basic_string<CharT>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>);
+ static_assert(
+ test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode, const AllocT>());
// ConstConvertibleStringView<CharT>
static_assert(std::constructible_from<StrStream,
- const ConstConvertibleStringView<CharT>,
+ const ConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
+ const AllocT>);
static_assert(test_convertible<StrStream,
- const ConstConvertibleStringView<CharT>,
+ const ConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- static_assert(std::constructible_from<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(test_convertible<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
// NonConstConvertibleStringView<CharT>
static_assert(!std::constructible_from<StrStream,
- NonConstConvertibleStringView<CharT>,
+ NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
+ const AllocT>);
static_assert(!test_convertible<StrStream,
- NonConstConvertibleStringView<CharT>,
+ NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
static_assert(!std::constructible_from<StrStream,
- const NonConstConvertibleStringView<CharT>,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
+ const AllocT>);
static_assert(!test_convertible<StrStream,
- const NonConstConvertibleStringView<CharT>,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- // nasty_char*
- using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
- static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
- static_assert(test_convertible<NStrStream, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
-
- // const nasty_char*
- static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
- static_assert(
- test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+ const AllocT>());
// Non-`string-view-like`
- static_assert(
- !std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>);
- static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>());
- static_assert(!std::constructible_from<StrStream, const int, std::ios_base::openmode, const test_allocator<CharT>>);
- static_assert(!test_convertible<StrStream, const int, std::ios_base::openmode, const test_allocator<CharT>>());
+ static_assert(!std::constructible_from<StrStream, const int, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const int, std::ios_base::openmode, const AllocT>());
// Non-mode
- static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, NonMode, const NonAllocator>);
- static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, NonMode, const NonAllocator>());
+ static_assert(
+ !std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>);
+ static_assert(
+ !test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>());
// Non-allocator
static_assert(!std::constructible_from<StrStream,
- const std::basic_string_view<CharT>,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
const NonAllocator>);
- static_assert(
- !test_convertible<StrStream, const std::basic_string_view<CharT>, std::ios_base::openmode, const NonAllocator>());
+ static_assert(!test_convertible<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const NonAllocator>());
}
template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
@@ -212,13 +165,21 @@ void test() {
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
test<char, constexpr_char_traits<char>, std::allocator<char>>();
test<char, std::char_traits<char>, test_allocator<char>>();
test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
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 03987d0a246c66..9f841d5230bfe3 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
@@ -32,103 +32,66 @@
#include "../../macros.h"
#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
+
+ // const nasty_char*
+ using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>>;
- using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
// `CharT*`
static_assert(std::constructible_from<StrStream, CharT*, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, CharT*, std::ios_base::openmode>());
- static_assert(std::constructible_from<CStrStream, CharT*, std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream, CharT*, std::ios_base::openmode>());
-
// `const CharT*`
static_assert(std::constructible_from<StrStream, const CharT*, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, const CharT*, std::ios_base::openmode>());
- static_assert(std::constructible_from<CStrStream, const CharT*, std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream, const CharT*, std::ios_base::openmode, std::ios_base::openmode>());
-
// `std::basic_string_view<CharT>`
- static_assert(std::constructible_from<StrStream,
- const std::basic_string_view<CharT, std::char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<StrStream,
- const std::basic_string_view<CharT, std::char_traits<CharT>>,
- std::ios_base::openmode>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream,
- const std::basic_string_view<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>());
+ static_assert(
+ std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode>());
// `std::basic_string<CharT>`
- static_assert(std::constructible_from<StrStream, const std::basic_string<CharT>, std::ios_base::openmode>);
- static_assert(!test_convertible<StrStream, const std::basic_string<CharT>, std::ios_base::openmode>());
-
- static_assert(std::constructible_from<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream,
- const std::basic_string<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>());
// ConstConvertibleStringView<CharT>
- static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>);
- static_assert(!test_convertible<StrStream, const ConstConvertibleStringView<CharT>, std::ios_base::openmode>());
-
- static_assert(std::constructible_from<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream,
- const ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>());
+ static_assert(
+ std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
// NonConstConvertibleStringView<CharT>
- static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
- static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
-
static_assert(
- !std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>);
- static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT>, std::ios_base::openmode>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>());
-
- static_assert(!std::constructible_from<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>);
- static_assert(!test_convertible<CStrStream,
- const NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>,
- std::ios_base::openmode>());
-
- // nasty_char*
- using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
- static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
- static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
-
- // const nasty_char*
- using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+ !std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
- static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
- static_assert(!test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode>());
+ static_assert(
+ !std::
+ constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
// Non-`string-view-like`
static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode>);
static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode>());
// Non-mode
- static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT>, const SomeObject>);
- static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT>, const SomeObject>());
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const SomeObject>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, const SomeObject>());
}
template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
@@ -163,13 +126,21 @@ void test() {
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
test<char, constexpr_char_traits<char>, std::allocator<char>>();
test<char, std::char_traits<char>, test_allocator<char>>();
test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
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 b688d7afcef7c9..eeb9f9645ba6fe 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
@@ -31,47 +31,36 @@
#include "../../macros.h"
#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(is_valid_argument_for_str_member<NStrStream, nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<NStrStream, const nasty_char*>);
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- using StrStream = std::basic_istringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>;
- using CStrStream = std::basic_istringstream<CharT, constexpr_char_traits<CharT>, test_allocator<CharT>>;
+ using StrStream = std::basic_istringstream<CharT, TraitsT, AllocT>;
static_assert(is_valid_argument_for_str_member<StrStream, CharT*>);
- static_assert(is_valid_argument_for_str_member<CStrStream, CharT*>);
-
static_assert(is_valid_argument_for_str_member<StrStream, const CharT*>);
- static_assert(is_valid_argument_for_str_member<CStrStream, const CharT*>);
-
- static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string_view<CharT>>);
- static_assert(
- is_valid_argument_for_str_member<CStrStream, std::basic_string_view<CharT, constexpr_char_traits<CharT>>>);
-
- static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string<CharT>>);
- static_assert(is_valid_argument_for_str_member<CStrStream, std::basic_string<CharT, constexpr_char_traits<CharT>>>);
-
- static_assert(is_valid_argument_for_str_member<StrStream, ConstConvertibleStringView<CharT>>);
- static_assert(
- is_valid_argument_for_str_member<CStrStream, ConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
-
- using NStrStream = std::basic_istringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
-
- static_assert(is_valid_argument_for_str_member<NStrStream, nasty_char*>);
- static_assert(is_valid_argument_for_str_member<NStrStream, const nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string_view<CharT, TraitsT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string<CharT, TraitsT, AllocT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, ConstConvertibleStringView<CharT, TraitsT>>);
static_assert(!is_valid_argument_for_str_member<StrStream, CharT>);
static_assert(!is_valid_argument_for_str_member<StrStream, int>);
static_assert(!is_valid_argument_for_str_member<StrStream, SomeObject>);
static_assert(!is_valid_argument_for_str_member<StrStream, std::nullptr_t>);
- static_assert(!is_valid_argument_for_str_member<StrStream, NonConstConvertibleStringView<CharT>>);
- static_assert(!is_valid_argument_for_str_member<CStrStream,
- NonConstConvertibleStringView<CharT, constexpr_char_traits<CharT>>>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, NonConstConvertibleStringView<CharT, TraitsT>>);
}
template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test() {
AllocT allocator;
- std::basic_istringstream<CharT, TraitsT, AllocT> ss( std::ios_base::in , allocator);
+ std::basic_istringstream<CharT, TraitsT, AllocT> ss(std::ios_base::in, allocator);
assert(ss.str().empty());
// const CharT*
@@ -96,13 +85,21 @@ void test() {
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
test<char, constexpr_char_traits<char>, std::allocator<char>>();
test<char, std::char_traits<char>, test_allocator<char>>();
test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
>From d43f5cdc9eb988d73c3cc30ed7c946335e5f33b3 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 13:44:08 +0200
Subject: [PATCH 25/31] Updated: `basic_ostringstream` tests
---
.../string_view.alloc.pass.cpp | 139 ++++++++-----
.../string_view.mode.alloc.pass.cpp | 192 +++++++++++-------
.../string_view.mode.pass.cpp | 142 ++++++++-----
.../str.string_view.pass.cpp | 80 ++++++--
4 files changed, 349 insertions(+), 204 deletions(-)
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
index 0b3515dc543b77..a8f905bde29c2f 100644
--- 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
@@ -18,97 +18,128 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_ostringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, nasty_char*, const AllocT>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, const nasty_char*, const AllocT>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, const AllocT>());
// `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>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, const AllocT>());
+
// `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>>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, std::basic_string_view<CharT, TraitsT>, const AllocT>());
+
// `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>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ static_assert(!std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, const AllocT>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const NonAllocator>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+ StrStream ss(CS("zmt"), allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string_view<CharT>
{
- const auto csv = SV("zmt");
- std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string<CharT>
{
- const auto cs = ST("zmt");
- std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.rdbuf()->get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 b63536f0e03719..6d4ff18e77bbf2 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
@@ -18,128 +18,172 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_ostringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(
+ test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, std::ios_base::openmode, const AllocT>());
// `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,
- const test_allocator<CharT>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, std::ios_base::openmode, const AllocT>());
+
// `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>,
+ static_assert(std::constructible_from<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
- test_allocator<CharT>>);
- static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const std::basic_string_view<CharT>,
+ const AllocT>);
+ static_assert(test_convertible<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
+
// `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>,
+ static_assert(std::constructible_from<StrStream,
+ const std::basic_string<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>);
- static_assert(test_convertible<std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const std::basic_string<CharT>,
- std::ios_base::openmode,
- const test_allocator<CharT>>());
-
- // String-view-like
+ const AllocT>);
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,
- const test_allocator<CharT>>());
+ test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode, const AllocT>());
- 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,
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrStream,
+ const ConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>);
+ static_assert(test_convertible<StrStream,
+ const ConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrStream,
+ NonConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>);
+ static_assert(!test_convertible<StrStream,
+ NonConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>());
+
+ static_assert(!std::constructible_from<StrStream,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>);
+ static_assert(!test_convertible<StrStream,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- // 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>>,
- const std::basic_string_view<CharT>,
- SomeObject,
- const NonAllocator>());
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>());
+
+ static_assert(!std::constructible_from<StrStream, const int, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const int, std::ios_base::openmode, const AllocT>());
- // Allocator
+ // Non-mode
+ static_assert(
+ !std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>);
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>>,
- const std::basic_string_view<CharT>,
+ !test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const NonAllocator>);
+ static_assert(!test_convertible<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- std::basic_ostringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
- CS("zmt"), std::ios_base::binary, ca);
+ StrStream ss(CS("zmt"), std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// 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, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// 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, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::binary, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.rdbuf()->get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::binary, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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
index a84198e24381a7..205c8ecff6ed01 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
@@ -18,99 +18,133 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_ostringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
+
+ // const nasty_char*
+ using NStrStream = std::basic_ostringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, CharT*, std::ios_base::openmode>());
// `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>());
+ static_assert(std::constructible_from<StrStream, const CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(
+ std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // ConstConvertibleStringView<CharT>
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>());
+ std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, 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
+ !test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(
+ !std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
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>());
+ !std::
+ constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode>());
+
+ // Non-mode
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const SomeObject>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
+
+ const AllocT allocator;
-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);
+ StrStream 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);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream 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);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::binary);
+ assert(ss.str() == CS("zmt"));
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::binary);
assert(ss.str() == CS("zmt"));
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 d0433c9347aa8c..0f8f748204d478 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
@@ -17,57 +17,93 @@
// void str(const T& t);
#include <cassert>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
+#include "test_allocator.h"
#include "test_macros.h"
-template <typename S, typename T>
-concept HasStr = requires(S s, const T& sv) {
- { s.str(sv) };
-};
+#include "../../concepts.h"
+#include "../../macros.h"
+#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ using NStrStream = std::basic_ostringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(is_valid_argument_for_str_member<NStrStream, nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<NStrStream, const nasty_char*>);
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrStream = std::basic_ostringstream<CharT, TraitsT, AllocT>;
- 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(is_valid_argument_for_str_member<StrStream, CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, const CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string_view<CharT, TraitsT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string<CharT, TraitsT, AllocT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, ConstConvertibleStringView<CharT, TraitsT>>);
- 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>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, CharT>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, int>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, SomeObject>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, std::nullptr_t>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, NonConstConvertibleStringView<CharT, TraitsT>>);
}
-#define CS(S) MAKE_CSTRING(CharT, S)
-#define ST(S) MAKE_STRING(CharT, S)
-#define SV(S) MAKE_STRING_VIEW(CharT, S)
-
-template <typename CharT>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test() {
- std::basic_ostringstream<CharT> ss;
+ AllocT allocator;
+
+ std::basic_ostringstream<CharT, TraitsT, AllocT> ss(std::ios_base::out, allocator);
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"));
- ss.str(ST("zmt"));
+
+ // std::basic_string<CharT>
+ ss.str(ST("zmt", allocator));
assert(ss.str() == CS("zmt"));
- const std::basic_string<CharT> s;
+
+ // ConstConvertibleStringView<CharT>
+ ss.str(ConstConvertibleStringView<CharT, TraitsT>{CS("da")});
+ assert(ss.str() == CS("da"));
+
+ const std::basic_string<CharT, TraitsT, AllocT> s(allocator);
ss.str(s);
assert(ss.str().empty());
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
#endif
return 0;
>From aa90f89dc86b553d3ea7b933374f72c27aff7024 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 14:03:38 +0200
Subject: [PATCH 26/31] Updated: `basic_stringstream` tests
---
.../string_view.alloc.pass.cpp | 137 ++++++++-----
.../string_view.mode.alloc.pass.cpp | 181 +++++++++++-------
.../string_view.mode.pass.cpp | 147 ++++++++------
.../str.string_view.pass.cpp | 80 +++++---
4 files changed, 347 insertions(+), 198 deletions(-)
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
index 3fe41d57341c30..a983be46af379c 100644
--- 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
@@ -18,95 +18,128 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, nasty_char*, const AllocT>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrStream, const nasty_char*, const AllocT>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, const AllocT>());
// `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>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, const AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, const AllocT>());
+
// `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>>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, std::basic_string_view<CharT, TraitsT>, const AllocT>());
+
// `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>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, const AllocT>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ static_assert(!std::constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, const AllocT>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const NonAllocator>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+ StrStream ss(CS("zmt"), allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string_view<CharT>
{
- const auto csv = SV("zmt");
- std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(csv, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// std::basic_string<CharT>
{
- const auto cs = ST("zmt");
- std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.rdbuf()->get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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
index be3d5d8b02059f..a4ebdacbe189ce 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
@@ -18,127 +18,172 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrStream, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(
+ test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, CharT*, std::ios_base::openmode, const AllocT>());
// `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>>());
+ static_assert(std::constructible_from<StrStream, const CharT*, AllocT>);
+ static_assert(test_convertible<StrStream, const CharT*, std::ios_base::openmode, const AllocT>());
+
// `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>,
+ static_assert(std::constructible_from<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
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>,
+ const AllocT>);
+ static_assert(test_convertible<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
+
// `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>,
+ static_assert(std::constructible_from<StrStream,
+ const std::basic_string<CharT, TraitsT>,
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>,
+ const AllocT>);
+ static_assert(
+ test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode, const AllocT>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrStream,
+ const ConstConvertibleStringView<CharT, TraitsT>,
+ std::ios_base::openmode,
+ const AllocT>);
+ static_assert(test_convertible<StrStream,
+ const ConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- // String-view-like
- static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const int,
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrStream,
+ NonConstConvertibleStringView<CharT, TraitsT>,
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,
+ const AllocT>);
+ static_assert(!test_convertible<StrStream,
+ NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const SomeObject,
+ static_assert(!std::constructible_from<StrStream,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
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,
+ const AllocT>);
+ static_assert(!test_convertible<StrStream,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- // 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>());
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode, const AllocT>());
+
+ static_assert(!std::constructible_from<StrStream, const int, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrStream, const int, std::ios_base::openmode, const AllocT>());
- // Allocator
- static_assert(!std::constructible_from<std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const std::basic_string_view<CharT>,
+ // Non-mode
+ static_assert(
+ !std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>);
+ static_assert(
+ !test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
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>,
+ static_assert(!test_convertible<StrStream,
+ const std::basic_string_view<CharT, TraitsT>,
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)
-#include <print>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- std::basic_stringstream<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
- CS("zmt"), std::ios_base::out | std::ios_base::in, ca);
+ StrStream ss(CS("zmt"), std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// 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::out | std::ios_base::in, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream ss(csv, std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
// 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::out | std::ios_base::in, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::out | std::ios_base::in, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.rdbuf()->get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.rdbuf()->get_allocator() == ca);
+ assert(ss.rdbuf()->get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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
index cc8be6f0c8dc12..0b9cf3b82831c3 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
@@ -18,98 +18,133 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
+
+ // const nasty_char*
+ using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, CharT*, std::ios_base::openmode>());
// `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>());
+ static_assert(std::constructible_from<StrStream, const CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(
+ std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(
+ std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(
+ !std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ static_assert(
+ !std::
+ constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode>());
+
+ // Non-mode
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const SomeObject>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
+
+ const AllocT allocator;
-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::out | std::ios_base::in);
+ StrStream 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::out | std::ios_base::in);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream 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::out | std::ios_base::in);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::out | std::ios_base::in);
+ assert(ss.str() == CS("zmt"));
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::out | std::ios_base::in);
assert(ss.str() == CS("zmt"));
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 f575c2f4d9622b..0cc8a9e368fac1 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
@@ -17,57 +17,93 @@
// void str(const T& t);
#include <cassert>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
+#include "test_allocator.h"
#include "test_macros.h"
-template <typename S, typename T>
-concept HasStr = requires(S s, const T& sv) {
- { s.str(sv) };
-};
+#include "../../concepts.h"
+#include "../../macros.h"
+#include "../../types.h"
-template <typename CharT>
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(is_valid_argument_for_str_member<NStrStream, nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<NStrStream, const nasty_char*>);
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrStream = std::basic_stringstream<CharT, TraitsT, AllocT>;
- 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(is_valid_argument_for_str_member<StrStream, CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, const CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string_view<CharT, TraitsT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, std::basic_string<CharT, TraitsT, AllocT>>);
+ static_assert(is_valid_argument_for_str_member<StrStream, ConstConvertibleStringView<CharT, TraitsT>>);
- 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>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, CharT>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, int>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, SomeObject>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, std::nullptr_t>);
+ static_assert(!is_valid_argument_for_str_member<StrStream, NonConstConvertibleStringView<CharT, TraitsT>>);
}
-#define CS(S) MAKE_CSTRING(CharT, S)
-#define ST(S) MAKE_STRING(CharT, S)
-#define SV(S) MAKE_STRING_VIEW(CharT, S)
-
-template <typename CharT>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test() {
- std::basic_stringstream<CharT> ss;
+ AllocT allocator;
+
+ std::basic_stringstream<CharT, TraitsT, AllocT> ss(std::ios_base::out | std::ios_base::in, allocator);
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"));
- ss.str(ST("zmt"));
+
+ // std::basic_string<CharT>
+ ss.str(ST("zmt", allocator));
assert(ss.str() == CS("zmt"));
- const std::basic_string<CharT> s;
+
+ // ConstConvertibleStringView<CharT>
+ ss.str(ConstConvertibleStringView<CharT, TraitsT>{CS("da")});
+ assert(ss.str() == CS("da"));
+
+ const std::basic_string<CharT, TraitsT, AllocT> s(allocator);
ss.str(s);
assert(ss.str().empty());
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
#endif
return 0;
>From d963bd5d64a83361a995fb58d9f9c54d3346d35a Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 18:57:48 +0200
Subject: [PATCH 27/31] Updated: `basic_stringbuf` tests
---
.../stringbuf.cons/string_view.alloc.pass.cpp | 137 +++++++++-----
.../string_view.mode.alloc.pass.cpp | 177 +++++++++++-------
.../stringbuf.cons/string_view.mode.pass.cpp | 146 +++++++++------
.../str.string_view.pass.cpp | 81 +++++---
4 files changed, 344 insertions(+), 197 deletions(-)
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
index 264ed301e9ffd8..082cf780e2144a 100644
--- 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
@@ -18,95 +18,128 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrBuf = std::basic_istringstream<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(std::constructible_from<NStrBuf, nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrBuf, nasty_char*, const AllocT>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrBuf, const nasty_char*, AllocT>);
+ static_assert(test_convertible<NStrBuf, const nasty_char*, const AllocT>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrBuf = std::basic_stringbuf<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrBuf, CharT*, const AllocT>);
+ static_assert(test_convertible<StrBuf, CharT*, const AllocT>());
// `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>>());
+ static_assert(std::constructible_from<StrBuf, const CharT*, const AllocT>);
+ static_assert(test_convertible<StrBuf, const CharT*, const AllocT>());
+
// `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>>());
+ static_assert(std::constructible_from<StrBuf, const std::basic_string_view<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrBuf, std::basic_string_view<CharT, TraitsT>, const AllocT>());
+
// `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>());
+ static_assert(std::constructible_from<StrBuf, const std::basic_string<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrBuf, const std::basic_string<CharT, TraitsT>, const AllocT>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrBuf, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(test_convertible<StrBuf, const ConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrBuf, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrBuf, NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ static_assert(!std::constructible_from<StrBuf, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>);
+ static_assert(!test_convertible<StrBuf, const NonConstConvertibleStringView<CharT, TraitsT>, const AllocT>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrBuf, const SomeObject, const AllocT>);
+ static_assert(!test_convertible<StrBuf, const SomeObject, const AllocT>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrBuf, const std::basic_string_view<CharT, TraitsT>, const NonAllocator>);
+ static_assert(!test_convertible<StrBuf, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrBuf = std::basic_stringbuf<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(CS("zmt"), ca);
+ StrBuf ss(CS("zmt"), allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
// 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);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrBuf ss(csv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
// std::basic_string<CharT>
{
- const auto cs = ST("zmt");
- const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(cs, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrBuf ss(cs, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrBuf ss(sv, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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
index 6f304125babb4d..61892271c1c461 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
@@ -18,126 +18,167 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrBuf = std::basic_stringbuf<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrBuf, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(test_convertible<NStrBuf, nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+
+ // const nasty_char*
+ static_assert(std::constructible_from<NStrBuf, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(
+ test_convertible<NStrBuf, const nasty_char*, std::ios_base::openmode, const test_allocator<nasty_char>>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
- struct NonAllocator {};
+ using StrBuf = std::basic_stringbuf<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrBuf, CharT*, AllocT>);
+ static_assert(test_convertible<StrBuf, CharT*, std::ios_base::openmode, const AllocT>());
// `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>>());
+ static_assert(std::constructible_from<StrBuf, const CharT*, AllocT>);
+ static_assert(test_convertible<StrBuf, const CharT*, std::ios_base::openmode, const AllocT>());
+
// `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>,
+ static_assert(std::constructible_from<StrBuf,
+ const std::basic_string_view<CharT, TraitsT>,
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>>());
+ const AllocT>);
+ static_assert(
+ test_convertible<StrBuf, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode, const AllocT>());
+
// `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>,
+ static_assert(
+ std::constructible_from<StrBuf, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode, const AllocT>);
+ static_assert(
+ test_convertible<StrBuf, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode, const AllocT>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(std::constructible_from<StrBuf,
+ const ConstConvertibleStringView<CharT, TraitsT>,
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>,
+ const AllocT>);
+ static_assert(test_convertible<StrBuf,
+ const ConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- // String-view-like
- static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const int,
+ // NonConstConvertibleStringView<CharT>
+ static_assert(!std::constructible_from<StrBuf,
+ NonConstConvertibleStringView<CharT, TraitsT>,
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,
+ const AllocT>);
+ static_assert(!test_convertible<StrBuf,
+ NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const SomeObject,
+ static_assert(!std::constructible_from<StrBuf,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
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,
+ const AllocT>);
+ static_assert(!test_convertible<StrBuf,
+ const NonConstConvertibleStringView<CharT, TraitsT>,
std::ios_base::openmode,
- const test_allocator<CharT>>());
+ const AllocT>());
- // 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>());
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrBuf, const SomeObject, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrBuf, const SomeObject, std::ios_base::openmode, const AllocT>());
+
+ static_assert(!std::constructible_from<StrBuf, const int, std::ios_base::openmode, const AllocT>);
+ static_assert(!test_convertible<StrBuf, const int, std::ios_base::openmode, const AllocT>());
- // Allocator
- static_assert(!std::constructible_from<std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>>,
- const std::basic_string_view<CharT>,
+ // Non-mode
+ static_assert(
+ !std::constructible_from<StrBuf, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>);
+ static_assert(!test_convertible<StrBuf, const std::basic_string_view<CharT, TraitsT>, NonMode, const NonAllocator>());
+
+ // Non-allocator
+ static_assert(!std::constructible_from<StrBuf,
+ const std::basic_string_view<CharT, TraitsT>,
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>,
+ static_assert(!test_convertible<StrBuf,
+ const std::basic_string_view<CharT, TraitsT>,
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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrBuf = std::basic_stringbuf<CharT, TraitsT, AllocT>;
-template <class CharT>
-static void test() {
- const test_allocator<CharT> ca;
+ const AllocT allocator;
// const CharT*
{
- std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> ss(
- CS("zmt"), std::ios_base::out | std::ios_base::in, ca);
+ StrBuf ss(CS("zmt"), std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
// 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::out | std::ios_base::in, ca);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrBuf ss(csv, std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
// 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::out | std::ios_base::in, ca);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrBuf ss(cs, std::ios_base::out | std::ios_base::in, allocator);
+ assert(ss.str() == CS("zmt"));
+ assert(ss.get_allocator() == allocator);
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrBuf ss(sv, std::ios_base::out | std::ios_base::in, allocator);
assert(ss.str() == CS("zmt"));
- assert(ss.get_allocator() == ca);
+ assert(ss.get_allocator() == allocator);
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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
index b7553214523c6e..ef7a3752608a17 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
@@ -18,97 +18,133 @@
#include <cassert>
#include <concepts>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-template <typename CharT>
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ // nasty_char*
+ using NStrStream = std::basic_stringbuf<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, nasty_char*, std::ios_base::openmode>());
+
+ // const nasty_char*
+ using NStrStream = std::basic_stringbuf<nasty_char, nasty_char_traits, test_allocator<nasty_char>>;
+
+ static_assert(std::constructible_from<NStrStream, const nasty_char*, test_allocator<nasty_char>>);
+ static_assert(!test_convertible<NStrStream, const nasty_char*, std::ios_base::openmode>());
+}
+
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrStream = std::basic_stringbuf<CharT, TraitsT, AllocT>;
+
+ // `CharT*`
+ static_assert(std::constructible_from<StrStream, CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, CharT*, std::ios_base::openmode>());
// `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>());
+ static_assert(std::constructible_from<StrStream, const CharT*, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, 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>());
+ static_assert(
+ std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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>());
+ static_assert(std::constructible_from<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const std::basic_string<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // ConstConvertibleStringView<CharT>
+ static_assert(
+ std::constructible_from<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const ConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // NonConstConvertibleStringView<CharT>
+ static_assert(
+ !std::constructible_from<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ static_assert(
+ !std::
+ constructible_from<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>);
+ static_assert(
+ !test_convertible<StrStream, const NonConstConvertibleStringView<CharT, TraitsT>, std::ios_base::openmode>());
+
+ // Non-`string-view-like`
+ static_assert(!std::constructible_from<StrStream, const SomeObject, std::ios_base::openmode>);
+ static_assert(!test_convertible<StrStream, const SomeObject, std::ios_base::openmode>());
+
+ // Non-mode
+ static_assert(!std::constructible_from<StrStream, const std::basic_string_view<CharT, TraitsT>, const SomeObject>);
+ static_assert(!test_convertible<StrStream, const std::basic_string_view<CharT, TraitsT>, 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 <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
+void test() {
+ using StrStream = std::basic_stringbuf<CharT, TraitsT, AllocT>;
+
+ const AllocT allocator;
-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::out | std::ios_base::in);
+ StrStream 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::out | std::ios_base::in);
+ const std::basic_string_view<CharT, TraitsT> csv = SV("zmt");
+ StrStream 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::out | std::ios_base::in);
+ const std::basic_string<CharT, TraitsT, AllocT> cs = ST("zmt", allocator);
+ StrStream ss(cs, std::ios_base::out | std::ios_base::in);
+ assert(ss.str() == CS("zmt"));
+ }
+ // ConstConvertibleStringView<CharT>
+ {
+ const ConstConvertibleStringView<CharT, TraitsT> sv{CS("zmt")};
+ StrStream ss(sv, std::ios_base::out | std::ios_base::in);
assert(ss.str() == CS("zmt"));
}
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<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 ac76756d0e8a3b..ea033109ba4362 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,58 +15,95 @@
// template<class T>
// void str(const T& t);
+
#include <cassert>
+#include <memory>
#include <sstream>
#include <string>
#include <string_view>
-#include "make_string.h"
+#include "constexpr_char_traits.h"
+#include "nasty_string.h"
+#include "test_allocator.h"
#include "test_macros.h"
-template <typename S, typename T>
-concept HasStr = requires(S s, const T& sv) {
- { s.str(sv) };
-};
+#include "../../concepts.h"
+#include "../../macros.h"
+#include "../../types.h"
+
+template <typename AllocT = std::allocator<nasty_char>>
+void test_sfinae_with_nasty_char() {
+ using NStrBuf = std::basic_stringbuf<nasty_char, nasty_char_traits, AllocT>;
+
+ static_assert(is_valid_argument_for_str_member<NStrBuf, nasty_char*>);
+ static_assert(is_valid_argument_for_str_member<NStrBuf, const nasty_char*>);
+}
-template <typename CharT>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test_sfinae() {
- struct SomeObject {};
+ using StrBuff = std::basic_stringbuf<CharT, TraitsT, AllocT>;
- 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(is_valid_argument_for_str_member<StrBuff, CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrBuff, const CharT*>);
+ static_assert(is_valid_argument_for_str_member<StrBuff, std::basic_string_view<CharT, TraitsT>>);
+ static_assert(is_valid_argument_for_str_member<StrBuff, std::basic_string<CharT, TraitsT, AllocT>>);
+ static_assert(is_valid_argument_for_str_member<StrBuff, ConstConvertibleStringView<CharT, TraitsT>>);
- 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>);
+ static_assert(!is_valid_argument_for_str_member<StrBuff, CharT>);
+ static_assert(!is_valid_argument_for_str_member<StrBuff, int>);
+ static_assert(!is_valid_argument_for_str_member<StrBuff, SomeObject>);
+ static_assert(!is_valid_argument_for_str_member<StrBuff, std::nullptr_t>);
+ static_assert(!is_valid_argument_for_str_member<StrBuff, NonConstConvertibleStringView<CharT, TraitsT>>);
}
-#define CS(S) MAKE_CSTRING(CharT, S)
-#define ST(S) MAKE_STRING(CharT, S)
-#define SV(S) MAKE_STRING_VIEW(CharT, S)
-
-template <typename CharT>
+template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename AllocT = std::allocator<CharT>>
void test() {
- std::basic_stringbuf<CharT> ss;
+ AllocT allocator;
+
+ std::basic_stringbuf<CharT, TraitsT, AllocT> ss(std::ios_base::in | std::ios_base::out, allocator);
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"));
- ss.str(ST("zmt"));
+
+ // std::basic_string<CharT>
+ ss.str(ST("zmt", allocator));
assert(ss.str() == CS("zmt"));
- const std::basic_string<CharT> s;
+
+ // ConstConvertibleStringView<CharT>
+ ss.str(ConstConvertibleStringView<CharT, TraitsT>{CS("da")});
+ assert(ss.str() == CS("da"));
+
+ const std::basic_string<CharT, TraitsT, AllocT> s(allocator);
ss.str(s);
assert(ss.str().empty());
}
int main(int, char**) {
+ test_sfinae_with_nasty_char();
+ test_sfinae_with_nasty_char<test_allocator<nasty_char>>();
test_sfinae<char>();
+ test_sfinae<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test_sfinae<char, std::char_traits<char>, test_allocator<char>>();
+ test_sfinae<char, constexpr_char_traits<char>, test_allocator<char>>();
test<char>();
+ test<char, constexpr_char_traits<char>, std::allocator<char>>();
+ test<char, std::char_traits<char>, test_allocator<char>>();
+ test<char, constexpr_char_traits<char>, test_allocator<char>>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test_sfinae<wchar_t>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test_sfinae<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test_sfinae<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
test<wchar_t>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, std::allocator<wchar_t>>();
+ test<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t>>();
+ test<wchar_t, constexpr_char_traits<wchar_t>, test_allocator<wchar_t>>();
#endif
return 0;
>From 93eacb7c14b04eb9adf4badfac4718463f83b295 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 19:05:40 +0200
Subject: [PATCH 28/31] Minor tweaks
---
.../istringstream.members/str.string_view.pass.cpp | 2 +-
.../ostringstream.members/str.string_view.pass.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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 eeb9f9645ba6fe..b4a48961a5e3e2 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
@@ -60,7 +60,7 @@ template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename A
void test() {
AllocT allocator;
- std::basic_istringstream<CharT, TraitsT, AllocT> ss(std::ios_base::in, allocator);
+ std::basic_istringstream<CharT, TraitsT, AllocT> ss(std::ios_base::binary, allocator);
assert(ss.str().empty());
// const CharT*
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 0f8f748204d478..b2f50c6d480593 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
@@ -60,7 +60,7 @@ template <typename CharT, typename TraitsT = std::char_traits<CharT>, typename A
void test() {
AllocT allocator;
- std::basic_ostringstream<CharT, TraitsT, AllocT> ss(std::ios_base::out, allocator);
+ std::basic_ostringstream<CharT, TraitsT, AllocT> ss(std::ios_base::binary, allocator);
assert(ss.str().empty());
// const CharT*
>From 6687aa346f12c5b26d96e0fadb1abbc41586a562 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 19 Feb 2024 19:11:58 +0200
Subject: [PATCH 29/31] Fix synopsis
---
.../istringstream/istringstream.cons/string_view.alloc.pass.cpp | 2 +-
.../istringstream.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../istringstream/istringstream.cons/string_view.mode.pass.cpp | 2 +-
.../ostringstream/ostringstream.cons/string_view.alloc.pass.cpp | 2 +-
.../ostringstream.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../ostringstream/ostringstream.cons/string_view.mode.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.alloc.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.mode.pass.cpp | 2 +-
9 files changed, 9 insertions(+), 9 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 adf34aff631a26..84ac6aa1bd0e1b 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_istringstream
// template<class T>
// basic_istringstream(const T& t, const Allocator& a);
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 b57cb26d17e111..0794e00be9c2bc 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_istringstream
// template<class T>
// basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
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 9f841d5230bfe3..f7a3ee64b91dcd 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_istringstream
// template<class T>
// explicit basic_istringstream(const T& t, ios_base::openmode which);
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
index a8f905bde29c2f..e89a79e3293bef 100644
--- 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_ostringstream
// template<class T>
// basic_ostringstream(const T& t, const Allocator& a);
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 6d4ff18e77bbf2..b5e0c725dfb865 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_ostringstream
// template<class T>
// basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);
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 205c8ecff6ed01..398a468c865c1b 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_ostringstream
// template<class T>
// explicit basic_ostringstream(const T& t, ios_base::openmode which);
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
index 082cf780e2144a..5dc6d814b1b929 100644
--- 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_stringbuf
// template<class T>
// basic_stringbuf(const T& t, const Allocator& a);
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 61892271c1c461..f734ced49dc05d 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_stringbuf
// template<class T>
// basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);
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 ef7a3752608a17..4fb0cf88eb88ef 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
@@ -11,7 +11,7 @@
// <sstream>
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
-// class basic_stringstream
+// class basic_stringbuf
// template<class T>
// explicit basic_stringbuf(const T& t, ios_base::openmode which);
>From 6cbaac73663713b9b873099775150c8c833e0824 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 3 Mar 2024 18:17:21 +0200
Subject: [PATCH 30/31] Improved helper header filenames
---
.../string.streams/{concepts.h => helper_concepts.h} | 6 +++---
.../string.streams/{macros.h => helper_macros.h} | 6 +++---
.../string.streams/{types.h => helper_types.h} | 6 +++---
.../istringstream.cons/string_view.alloc.pass.cpp | 4 ++--
.../istringstream.cons/string_view.mode.alloc.pass.cpp | 4 ++--
.../istringstream.cons/string_view.mode.pass.cpp | 4 ++--
.../istringstream.members/str.string_view.pass.cpp | 6 +++---
.../ostringstream.cons/string_view.alloc.pass.cpp | 4 ++--
.../ostringstream.cons/string_view.mode.alloc.pass.cpp | 4 ++--
.../ostringstream.cons/string_view.mode.pass.cpp | 4 ++--
.../ostringstream.members/str.string_view.pass.cpp | 6 +++---
.../stringbuf/stringbuf.cons/string_view.alloc.pass.cpp | 4 ++--
.../stringbuf.cons/string_view.mode.alloc.pass.cpp | 6 +++---
.../stringbuf/stringbuf.cons/string_view.mode.pass.cpp | 4 ++--
.../stringbuf/stringbuf.members/str.string_view.pass.cpp | 6 +++---
.../stringstream.cons/string_view.alloc.pass.cpp | 4 ++--
.../stringstream.cons/string_view.mode.alloc.pass.cpp | 4 ++--
.../stringstream.cons/string_view.mode.pass.cpp | 4 ++--
.../stringstream.members/str.string_view.pass.cpp | 8 ++++----
19 files changed, 47 insertions(+), 47 deletions(-)
rename libcxx/test/std/input.output/string.streams/{concepts.h => helper_concepts.h} (72%)
rename libcxx/test/std/input.output/string.streams/{macros.h => helper_macros.h} (78%)
rename libcxx/test/std/input.output/string.streams/{types.h => helper_types.h} (94%)
diff --git a/libcxx/test/std/input.output/string.streams/concepts.h b/libcxx/test/std/input.output/string.streams/helper_concepts.h
similarity index 72%
rename from libcxx/test/std/input.output/string.streams/concepts.h
rename to libcxx/test/std/input.output/string.streams/helper_concepts.h
index d31a33b4c7e22d..18f6e5474164c5 100644
--- a/libcxx/test/std/input.output/string.streams/concepts.h
+++ b/libcxx/test/std/input.output/string.streams/helper_concepts.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
-#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
+#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H
template <typename S, typename T>
concept is_valid_argument_for_str_member = requires(S s, const T& sv) {
{ s.str(sv) };
};
-#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_CONCEPTS_H
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_CONCEPTS_H
diff --git a/libcxx/test/std/input.output/string.streams/macros.h b/libcxx/test/std/input.output/string.streams/helper_macros.h
similarity index 78%
rename from libcxx/test/std/input.output/string.streams/macros.h
rename to libcxx/test/std/input.output/string.streams/helper_macros.h
index 964aea57100e79..4a7d22daa788cb 100644
--- a/libcxx/test/std/input.output/string.streams/macros.h
+++ b/libcxx/test/std/input.output/string.streams/helper_macros.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_MACROS_H
-#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_MACROS_H
+#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_MACROS_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_MACROS_H
#include "make_string.h"
@@ -15,4 +15,4 @@
#define ST(S, a) std::basic_string<CharT, TraitsT, AllocT>(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S), a)
#define SV(S) std::basic_string_view<CharT, TraitsT>(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S))
-#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_MACROS_H
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_MACROS_H
diff --git a/libcxx/test/std/input.output/string.streams/types.h b/libcxx/test/std/input.output/string.streams/helper_types.h
similarity index 94%
rename from libcxx/test/std/input.output/string.streams/types.h
rename to libcxx/test/std/input.output/string.streams/helper_types.h
index 671666b2251fdb..8bd830d0fbda3b 100644
--- a/libcxx/test/std/input.output/string.streams/types.h
+++ b/libcxx/test/std/input.output/string.streams/helper_types.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H
-#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H
+#ifndef TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_TYPES_H
+#define TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_TYPES_H
#include <string_view>
#include <concepts>
@@ -72,4 +72,4 @@ struct NonMode {};
struct NonAllocator {};
-#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_TYPES_H
+#endif // TEST_STD_INPUTOUTPUT_STRINGSTREAMS_HELPER_TYPES_H
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 84ac6aa1bd0e1b..95cf5cdb879306 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 0794e00be9c2bc..c0dc8fb8edc927 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,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../heper_macros.h"
+#include "../../heper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 f7a3ee64b91dcd..d08e4bc5e21d74 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 b4a48961a5e3e2..135bf97c2c75ea 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
@@ -27,9 +27,9 @@
#include "test_allocator.h"
#include "test_macros.h"
-#include "../../concepts.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_concepts.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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
index e89a79e3293bef..0d07baeeab138a 100644
--- 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 b5e0c725dfb865..528d289e393f21 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 398a468c865c1b..d859fbf2df70bb 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../heper_macros.h"
+#include "../../heper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 b2f50c6d480593..5f81dbebd45f9c 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
@@ -27,9 +27,9 @@
#include "test_allocator.h"
#include "test_macros.h"
-#include "../../concepts.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_concepts.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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
index 5dc6d814b1b929..5f44c12e9808d0 100644
--- 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 f734ced49dc05d..78d80cdb78f997 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
@@ -28,9 +28,9 @@
#include "test_allocator.h"
#include "test_convertible.h"
#include "test_macros.h"
-
-#include "../../macros.h"
-#include "../../types.h"
+helper_
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 4fb0cf88eb88ef..52dab6b106853e 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 ea033109ba4362..08131c9cb58cf3 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
@@ -27,9 +27,9 @@
#include "test_allocator.h"
#include "test_macros.h"
-#include "../../concepts.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_concepts.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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
index a983be46af379c..7b2dcd570e9fdc 100644
--- 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 a4ebdacbe189ce..7583a2542fd5c9 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 0b9cf3b82831c3..828a3a30160097 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
@@ -29,8 +29,8 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../macros.h"
-#include "../../types.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
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 0cc8a9e368fac1..bedf432d34b2be 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
@@ -27,10 +27,10 @@
#include "test_allocator.h"
#include "test_macros.h"
-#include "../../concepts.h"
-#include "../../macros.h"
-#include "../../types.h"
-
+#include "../../helper_concepts.h"
+#include "../../helper_macros.h"
+#include "../../helper_types.h"
+helper_
template <typename AllocT = std::allocator<nasty_char>>
void test_sfinae_with_nasty_char() {
using NStrStream = std::basic_stringstream<nasty_char, nasty_char_traits, AllocT>;
>From 2c0b4a1a12046711f569215c774486fdb7036fc7 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sun, 3 Mar 2024 18:24:49 +0200
Subject: [PATCH 31/31] One more rename
---
.../string.streams/{helper_macros.h => helper_string_macros.h} | 0
.../istringstream/istringstream.cons/string_view.alloc.pass.cpp | 2 +-
.../istringstream.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../istringstream/istringstream.cons/string_view.mode.pass.cpp | 2 +-
.../istringstream.members/str.string_view.pass.cpp | 2 +-
.../ostringstream/ostringstream.cons/string_view.alloc.pass.cpp | 2 +-
.../ostringstream.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../ostringstream/ostringstream.cons/string_view.mode.pass.cpp | 2 +-
.../ostringstream.members/str.string_view.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.alloc.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../stringbuf/stringbuf.cons/string_view.mode.pass.cpp | 2 +-
.../stringbuf/stringbuf.members/str.string_view.pass.cpp | 2 +-
.../stringstream/stringstream.cons/string_view.alloc.pass.cpp | 2 +-
.../stringstream.cons/string_view.mode.alloc.pass.cpp | 2 +-
.../stringstream/stringstream.cons/string_view.mode.pass.cpp | 2 +-
.../stringstream/stringstream.members/str.string_view.pass.cpp | 2 +-
17 files changed, 16 insertions(+), 16 deletions(-)
rename libcxx/test/std/input.output/string.streams/{helper_macros.h => helper_string_macros.h} (100%)
diff --git a/libcxx/test/std/input.output/string.streams/helper_macros.h b/libcxx/test/std/input.output/string.streams/helper_string_macros.h
similarity index 100%
rename from libcxx/test/std/input.output/string.streams/helper_macros.h
rename to libcxx/test/std/input.output/string.streams/helper_string_macros.h
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 95cf5cdb879306..641773ce7a686c 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 c0dc8fb8edc927..0081e16f86ca8b 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,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../heper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../heper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 d08e4bc5e21d74..e6f4763010615f 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 135bf97c2c75ea..06be38846286c1 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
@@ -28,7 +28,7 @@
#include "test_macros.h"
#include "../../helper_concepts.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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
index 0d07baeeab138a..dedf8d9db99f2e 100644
--- 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 528d289e393f21..9e1ca8839035d4 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 d859fbf2df70bb..115dc4c1135003 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../heper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../heper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 5f81dbebd45f9c..ff072d52e3595f 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
@@ -28,7 +28,7 @@
#include "test_macros.h"
#include "../../helper_concepts.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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
index 5f44c12e9808d0..b25d81c81389f4 100644
--- 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 78d80cdb78f997..1807d3b2a5a720 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
helper_
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 52dab6b106853e..a6610e38521c28 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 08131c9cb58cf3..f1846c8f43a683 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
@@ -28,7 +28,7 @@
#include "test_macros.h"
#include "../../helper_concepts.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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
index 7b2dcd570e9fdc..c402fa6b941050 100644
--- 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 7583a2542fd5c9..c279dee25d72dc 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 828a3a30160097..ae7bb45601008a 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
@@ -29,7 +29,7 @@
#include "test_convertible.h"
#include "test_macros.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
template <typename AllocT = std::allocator<nasty_char>>
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 bedf432d34b2be..a1db74f0e2fb47 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
@@ -28,7 +28,7 @@
#include "test_macros.h"
#include "../../helper_concepts.h"
-#include "../../helper_macros.h"
+#include "../../heper_string_macros.h"
#include "../../helper_types.h"
helper_
template <typename AllocT = std::allocator<nasty_char>>
More information about the libcxx-commits
mailing list