From: Thomas Rodgers <trodg...@redhat.com>
* Note: depends on a sufficiently C++20ified basic_stringbuf<>.
libstdc++/Changelog:
libstdc++-v3/include/Makefile.am (std_headers): Add new header.
libstdc++-v3/include/Makefile.in: Regenerate.
libstdc++-v3/include/std/streambuf
(__detail::__streambuf_core_access): Define.
(basic_streambuf): Befriend __detail::__streambuf_core_access.
libstdc++-v3/include/std/syncstream: New header.
libstdc++-v3/include/std/version: Add __cpp_lib_syncbuf:
libstdc++-v3/testsuite/27_io/basic_syncbuf/1.cc: New test.
libstdc++-v3/testsuite/27_io/basic_syncbuf/2.cc: Likewise.
libstdc++-v3/testsuite/27_io/basic_syncbuf/basic_ops/1.cc:
Likewise.
libstdc++-v3/testsuite/27_io/basic_syncbuf/requirements/types.cc:
Likewise.
libstdc++-v3/testsuite/27_io/basic_syncbuf/sync_ops/1.cc:
Likewise.
libstdc++-v3/testsuite/27_io/basic_syncstream/1.cc: Likewise.
libstdc++-v3/testsuite/27_io/basic_syncstream/2.cc: Likewise.
libstdc++-v3/testsuite/27_io/basic_syncstream/basic_ops/1.cc:
Likewise.
libstdc++-v3/testsuite/27_io/basic_syncstream/requirements/types.cc:
Likewise.
---
libstdc++-v3/include/Makefile.am | 1 +
libstdc++-v3/include/Makefile.in | 1 +
libstdc++-v3/include/std/streambuf | 81 +++++
libstdc++-v3/include/std/syncstream | 333 ++++++++++++++++++
libstdc++-v3/include/std/version | 4 +
.../testsuite/27_io/basic_syncbuf/1.cc | 28 ++
.../testsuite/27_io/basic_syncbuf/2.cc | 27 ++
.../27_io/basic_syncbuf/basic_ops/1.cc | 138 ++++++++
.../27_io/basic_syncbuf/requirements/types.cc | 42 +++
.../27_io/basic_syncbuf/sync_ops/1.cc | 130 +++++++
.../testsuite/27_io/basic_syncstream/1.cc | 28 ++
.../testsuite/27_io/basic_syncstream/2.cc | 27 ++
.../27_io/basic_syncstream/basic_ops/1.cc | 135 +++++++
.../basic_syncstream/requirements/types.cc | 43 +++
14 files changed, 1018 insertions(+)
create mode 100644 libstdc++-v3/include/std/syncstream
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncbuf/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncbuf/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncbuf/basic_ops/1.cc
create mode 100644
libstdc++-v3/testsuite/27_io/basic_syncbuf/requirements/types.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncbuf/sync_ops/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncstream/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncstream/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_syncstream/basic_ops/1.cc
create mode 100644
libstdc++-v3/testsuite/27_io/basic_syncstream/requirements/types.cc
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 28d273924ee..61aaff7a2f4 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -73,6 +73,7 @@ std_headers = \
${std_srcdir}/shared_mutex \
${std_srcdir}/span \
${std_srcdir}/sstream \
+ ${std_srcdir}/syncstream \
${std_srcdir}/stack \
${std_srcdir}/stdexcept \
${std_srcdir}/stop_token \
diff --git a/libstdc++-v3/include/std/streambuf
b/libstdc++-v3/include/std/streambuf
index cae35e75bda..d6053e4c1ed 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -48,6 +48,84 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define _IsUnused __attribute__ ((__unused__))
+ template<typename _CharT, typename _Traits>
+ class basic_streambuf;
+
+#if __cplusplus > 201703L
+ namespace __detail
+ {
+ struct __streambuf_core_access
+ {
+ template<typename _CharT, typename _Traits>
+ static void
+ _S_imbue(basic_streambuf<_CharT, _Traits>& __b, const locale& __loc)
+ { __b.imbue(__loc); }
+
+ template<typename _CharT, typename _Traits>
+ static basic_streambuf<_CharT, _Traits>*
+ _S_setbuf(basic_streambuf<_CharT, _Traits>& __b,
+ _CharT* __c, streamsize __n)
+ { return __b.setbuf(__c, __n); }
+
+ template<typename _CharT, typename _Traits>
+ static typename _Traits::pos_type
+ _S_seekoff(basic_streambuf<_CharT, _Traits>& __b,
+ typename _Traits::off_type __off, ios_base::seekdir __dir,
+ ios_base::openmode __mode)
+ { return __b.seekoff(__off, __dir, __mode); }
+
+ template<typename _CharT, typename _Traits>
+ static typename _Traits::pos_type
+ _S_seekpos(basic_streambuf<_CharT, _Traits>& __b,
+ typename _Traits::pos_type __pos, ios_base::openmode __mode)
+ { return __b.seekpos(__pos, __mode); }
+
+ template<typename _CharT, typename _Traits>
+ static int
+ _S_sync(basic_streambuf<_CharT, _Traits>& __b)
+ { return __b.sync(); }
+
+ template<typename _CharT, typename _Traits>
+ static streamsize
+ _S_showmanyc(basic_streambuf<_CharT, _Traits>& __b)
+ { return __b.showmanyc(); }
+
+ template<typename _CharT, typename _Traits>
+ static streamsize
+ _S_xsgetn(basic_streambuf<_CharT, _Traits>& __b, _CharT* __s,
streamsize __n)
+ { return __b.xsgetn(__s, __n); }
+
+ template<typename _CharT, typename _Traits>
+ static typename _Traits::int_type
+ _S_underflow(basic_streambuf<_CharT, _Traits>& __b)
+ { return __b.underflow(); }
+
+ template<typename _CharT, typename _Traits>
+ static typename _Traits::int_type
+ _S_uflow(basic_streambuf<_CharT, _Traits>& __b)
+ { return __b.uflow(); }
+
+ template<typename _CharT, typename _Traits>
+ static typename _Traits::int_type
+ _S_pbackfail(basic_streambuf<_CharT, _Traits>& __b,
+ typename _Traits::int_type __c)
+ { return __b.pbackfail(__c); }
+
+ template<typename _CharT, typename _Traits>
+ static streamsize
+ _S_xsputn(basic_streambuf<_CharT, _Traits>& __b,
+ const typename _Traits::char_type* __s, streamsize __n)
+ { return __b.xsputn(__s, __n); }
+
+ template<typename _CharT, typename _Traits>
+ typename _Traits::int_type
+ _S_overflow(basic_streambuf<_CharT, _Traits>& __b,
+ typename _Traits::int_type __c)
+ { return __b.overflow(__c); }
+ };
+ }
+#endif // C++20
+
template<typename _CharT, typename _Traits>
streamsize
__copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
@@ -456,6 +534,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return this->xsputn(__s, __n); }
protected:
+#if __cplusplus > 201703L
+ friend __detail::__streambuf_core_access;
+#endif
/**
* @brief Base constructor.
*
diff --git a/libstdc++-v3/include/std/syncstream
b/libstdc++-v3/include/std/syncstream
new file mode 100644
index 00000000000..0a034ed03f4
--- /dev/null
+++ b/libstdc++-v3/include/std/syncstream
@@ -0,0 +1,333 @@
+// <syncstream> -*- C++ -*-
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received __a copy of the GNU General Public License and
+// __a copy of the GCC Runtime Library Exception along with this program;