[gcc r13-271] libstdc++: Add <spanstream> declarations to <iosfwd> [PR105284]

Jonathan Wakely redi@gcc.gnu.org
Tue May 10 15:40:46 GMT 2022


https://gcc.gnu.org/g:ca97c87758d450a946cac31b0db43da0039fabf1

commit r13-271-gca97c87758d450a946cac31b0db43da0039fabf1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue May 10 13:06:47 2022 +0100

    libstdc++: Add <spanstream> declarations to <iosfwd> [PR105284]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/105284
            * include/std/iosfwd: Add declarations for <spanstream> class
            templates and typedefs.
            * include/std/spanstream (basic_spanbuf, basic_ispanstream)
            (basic_ospanstream, basic_spanstream): Remove default template
            arguments.
            * testsuite/27_io/headers/iosfwd/synopsis.cc: Add <spanstream>
            declarations.
            * testsuite/27_io/headers/iosfwd/types.cc: Check <spanstream>
            default arguments.

Diff:
---
 libstdc++-v3/include/std/iosfwd                    | 23 ++++++++++
 libstdc++-v3/include/std/spanstream                |  8 ++--
 .../testsuite/27_io/headers/iosfwd/synopsis.cc     | 13 ++++++
 .../testsuite/27_io/headers/iosfwd/types.cc        | 50 ++++++++++++++++++++++
 4 files changed, 90 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/std/iosfwd b/libstdc++-v3/include/std/iosfwd
index c8c67c86c3b..ddf0c953856 100644
--- a/libstdc++-v3/include/std/iosfwd
+++ b/libstdc++-v3/include/std/iosfwd
@@ -225,6 +225,29 @@ _GLIBCXX_END_NAMESPACE_CXX11
 #endif
 #endif // C++20 && CXX11_ABI
 
+#if __cplusplus > 202002L
+  template<typename _CharT, typename _Traits = char_traits<_CharT>>
+    class basic_spanbuf;
+  template<typename _CharT, typename _Traits = char_traits<_CharT>>
+    class basic_ispanstream;
+  template<typename _CharT, typename _Traits = char_traits<_CharT>>
+    class basic_ospanstream;
+  template<typename _CharT, typename _Traits = char_traits<_CharT>>
+    class basic_spanstream;
+
+  using spanbuf     = basic_spanbuf<char>;
+  using ispanstream = basic_ispanstream<char>;
+  using ospanstream = basic_ospanstream<char>;
+  using spanstream  = basic_spanstream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  using wspanbuf     = basic_spanbuf<wchar_t>;
+  using wispanstream = basic_ispanstream<wchar_t>;
+  using wospanstream = basic_ospanstream<wchar_t>;
+  using wspanstream  = basic_spanstream<wchar_t>;
+#endif
+#endif // C++23
+
   /** @}  */
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/std/spanstream b/libstdc++-v3/include/std/spanstream
index 000bda52a1e..5855b286efe 100644
--- a/libstdc++-v3/include/std/spanstream
+++ b/libstdc++-v3/include/std/spanstream
@@ -45,7 +45,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #define __cpp_lib_spanstream 202106L
 
-template<typename _CharT, typename _Traits = char_traits<_CharT>>
+template<typename _CharT, typename _Traits>
   class basic_spanbuf
   : public basic_streambuf<_CharT, _Traits>
   {
@@ -218,7 +218,7 @@ template<typename _CharT, typename _Traits>
 using spanbuf = basic_spanbuf<char>;
 using wspanbuf = basic_spanbuf<wchar_t>;
 
-template<typename _CharT, typename _Traits = char_traits<_CharT>>
+template<typename _CharT, typename _Traits>
   class basic_ispanstream
   : public basic_istream<_CharT, _Traits>
   {
@@ -310,7 +310,7 @@ template<typename _CharT, typename _Traits>
 using ispanstream = basic_ispanstream<char>;
 using wispanstream = basic_ispanstream<wchar_t>;
 
-template<typename _CharT, typename _Traits = char_traits<_CharT>>
+template<typename _CharT, typename _Traits>
   class basic_ospanstream
   : public basic_ostream<_CharT, _Traits>
   {
@@ -378,7 +378,7 @@ template<typename _CharT, typename _Traits>
 using ospanstream = basic_ospanstream<char>;
 using wospanstream = basic_ospanstream<wchar_t>;
 
-template<typename _CharT, typename _Traits = char_traits<_CharT>>
+template<typename _CharT, typename _Traits>
   class basic_spanstream
   : public basic_iostream<_CharT, _Traits>
   {
diff --git a/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
index 48f733bf28a..467d63609bd 100644
--- a/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
+++ b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
@@ -75,6 +75,12 @@ _GLIBCXX_END_NAMESPACE_CXX11
   typedef basic_ostringstream<char> ostringstream;
   typedef basic_stringstream<char>  stringstream;
 
+#if __cplusplus > 202002L
+  typedef basic_spanbuf<char>     spanbuf;
+  typedef basic_ispanstream<char> ispanstream;
+  typedef basic_ospanstream<char> ospanstream;
+  typedef basic_spanstream<char>  spanstream;
+#endif
 
   typedef basic_filebuf<char>  filebuf;
   typedef basic_ifstream<char> ifstream;
@@ -96,6 +102,13 @@ _GLIBCXX_END_NAMESPACE_CXX11
   typedef basic_ostringstream<wchar_t> wostringstream;
   typedef basic_stringstream<wchar_t>  wstringstream;
 
+#if __cplusplus > 202002L
+  typedef basic_spanbuf<wchar_t>     wspanbuf;
+  typedef basic_ispanstream<wchar_t> wispanstream;
+  typedef basic_ospanstream<wchar_t> wospanstream;
+  typedef basic_spanstream<wchar_t>  wspanstream;
+#endif
+
   typedef basic_filebuf<wchar_t>  wfilebuf;
   typedef basic_ifstream<wchar_t> wifstream;
   typedef basic_ofstream<wchar_t> wofstream;
diff --git a/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc b/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc
index e2c9c9b8dfa..baf37e910af 100644
--- a/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc
+++ b/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc
@@ -115,6 +115,56 @@ static_assert(Same<basic_stringstream<wchar_t>,
 		   >::value,
     "std::basic_stringstream<wchar_t> has the correct default template argument");
 
+#if __cplusplus > 202002L
+using std::basic_spanbuf;
+
+static_assert(Same<basic_spanbuf<char>,
+		   basic_spanbuf<char, Traits<char>>
+		   >::value,
+    "std::basic_spanbuf<char> has the correct default template argument");
+
+static_assert(Same<basic_spanbuf<wchar_t>,
+		   basic_spanbuf<wchar_t, Traits<wchar_t>>
+		   >::value,
+    "std::basic_spanbuf<wchar_t> has the correct default template argument");
+
+using std::basic_ispanstream;
+
+static_assert(Same<basic_ispanstream<char>,
+		   basic_ispanstream<char, Traits<char>>
+		   >::value,
+    "std::basic_ispanstream<char> has the correct default template argument");
+
+static_assert(Same<basic_ispanstream<wchar_t>,
+		   basic_ispanstream<wchar_t, Traits<wchar_t>>
+		   >::value,
+    "std::basic_ispanstream<wchar_t> has the correct default template argument");
+
+using std::basic_ospanstream;
+
+static_assert(Same<basic_ospanstream<char>,
+		   basic_ospanstream<char, Traits<char>>
+		   >::value,
+    "std::basic_ospanstream<char> has the correct default template argument");
+
+static_assert(Same<basic_ospanstream<wchar_t>,
+		   basic_ospanstream<wchar_t, Traits<wchar_t>>
+		   >::value,
+    "std::basic_ospanstream<wchar_t> has the correct default template argument");
+
+using std::basic_spanstream;
+
+static_assert(Same<basic_spanstream<char>,
+		   basic_spanstream<char, Traits<char>>
+		   >::value,
+    "std::basic_spanstream<char> has the correct default template argument");
+
+static_assert(Same<basic_spanstream<wchar_t>,
+		   basic_spanstream<wchar_t, Traits<wchar_t>>
+		   >::value,
+    "std::basic_spanstream<wchar_t> has the correct default template argument");
+#endif
+
 using std::basic_filebuf;
 
 static_assert(Same<basic_filebuf<char>,


More information about the Gcc-cvs mailing list