summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-05-10 13:03:14 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-05-10 18:24:19 +0100
commit3e6067bdcab5f677526d80325b9b8dc03f49024d (patch)
tree1836c708ffec9f68191d2134ec6e1d47b0864149 /libstdc++-v3
parentab8a8d053734d6abc6ee9c5bfb772ff95ba74fc9 (diff)
libstdc++: Add <syncstream> declarations to <iosfwd> [PR105284]
libstdc++-v3/ChangeLog: PR libstdc++/105284 * include/std/iosfwd: Add declarations for <synstream> class templates and typedefs. * include/std/syncstream (basic_syncbuf, basic_osyncstream): Remove default template arguments. * testsuite/27_io/headers/iosfwd/synopsis.cc: New test. * testsuite/27_io/headers/iosfwd/types.cc: New test. (cherry picked from commit 1807e07825a86916bbfddca470708c5a8f613612)
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/std/iosfwd18
-rw-r--r--libstdc++-v3/include/std/syncstream6
-rw-r--r--libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc119
-rw-r--r--libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc214
4 files changed, 353 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/iosfwd b/libstdc++-v3/include/std/iosfwd
index 2d79a131631..c8c67c86c3b 100644
--- a/libstdc++-v3/include/std/iosfwd
+++ b/libstdc++-v3/include/std/iosfwd
@@ -207,6 +207,24 @@ _GLIBCXX_END_NAMESPACE_CXX11
/// Class for @c wchar_t mixed input and output file streams.
typedef basic_fstream<wchar_t> wfstream;
#endif
+
+#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Allocator = allocator<_CharT>>
+ class basic_syncbuf;
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Allocator = allocator<_CharT>>
+ class basic_osyncstream;
+
+ using syncbuf = basic_syncbuf<char>;
+ using osyncstream = basic_osyncstream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ using wsyncbuf = basic_syncbuf<wchar_t>;
+ using wosyncstream = basic_osyncstream<wchar_t>;
+#endif
+#endif // C++20 && CXX11_ABI
+
/** @} */
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/std/syncstream b/libstdc++-v3/include/std/syncstream
index 3cf2296f723..7a4f731ddd9 100644
--- a/libstdc++-v3/include/std/syncstream
+++ b/libstdc++-v3/include/std/syncstream
@@ -50,8 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
- template<typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT>>
+ template<typename _CharT, typename _Traits, typename _Alloc>
class basic_syncbuf : public __syncbuf_base<_CharT, _Traits>
{
public:
@@ -241,8 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__mutex _M_mtx;
};
- template <typename _CharT, typename _Traits = char_traits<_CharT>,
- typename _Alloc = allocator<_CharT>>
+ template <typename _CharT, typename _Traits, typename _Alloc>
class basic_osyncstream : public basic_ostream<_CharT, _Traits>
{
using __ostream_type = basic_ostream<_CharT, _Traits>;
diff --git a/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
new file mode 100644
index 00000000000..48f733bf28a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
@@ -0,0 +1,119 @@
+// { dg-do compile }
+
+#include <iosfwd>
+
+namespace std
+{
+ // [iosfwd.syn]
+
+ template<class charT> struct char_traits;
+ template<> struct char_traits<char>;
+#if __cplusplus >= 202002L
+ template<> struct char_traits<char8_t>;
+#endif
+#if __cplusplus >= 201103L
+ template<> struct char_traits<char16_t>;
+ template<> struct char_traits<char32_t>;
+#endif
+ template<> struct char_traits<wchar_t>;
+
+ template<class T> class allocator;
+
+ template<class charT, class traits>
+ class basic_ios;
+ template<class charT, class traits>
+ class basic_streambuf;
+ template<class charT, class traits>
+ class basic_istream;
+ template<class charT, class traits>
+ class basic_ostream;
+ template<class charT, class traits>
+ class basic_iostream;
+
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template<class charT, class traits, class Allocator>
+ class basic_stringbuf;
+ template<class charT, class traits, class Allocator>
+ class basic_istringstream;
+ template<class charT, class traits, class Allocator>
+ class basic_ostringstream;
+ template<class charT, class traits, class Allocator>
+ class basic_stringstream;
+_GLIBCXX_END_NAMESPACE_CXX11
+
+ template<class charT, class traits>
+ class basic_filebuf;
+ template<class charT, class traits>
+ class basic_ifstream;
+ template<class charT, class traits>
+ class basic_ofstream;
+ template<class charT, class traits>
+ class basic_fstream;
+
+#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
+ template<class charT, class traits, class Allocator>
+ class basic_syncbuf;
+ template<class charT, class traits, class Allocator>
+ class basic_osyncstream;
+#endif
+
+ template<class charT, class traits>
+ class istreambuf_iterator;
+ template<class charT, class traits>
+ class ostreambuf_iterator;
+
+ typedef basic_ios<char> ios;
+ typedef basic_ios<wchar_t> wios;
+
+ typedef basic_streambuf<char> streambuf;
+ typedef basic_istream<char> istream;
+ typedef basic_ostream<char> ostream;
+ typedef basic_iostream<char> iostream;
+
+ typedef basic_stringbuf<char> stringbuf;
+ typedef basic_istringstream<char> istringstream;
+ typedef basic_ostringstream<char> ostringstream;
+ typedef basic_stringstream<char> stringstream;
+
+
+ typedef basic_filebuf<char> filebuf;
+ typedef basic_ifstream<char> ifstream;
+ typedef basic_ofstream<char> ofstream;
+ typedef basic_fstream<char> fstream;
+
+#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
+ typedef basic_syncbuf<char> syncbuf;
+ typedef basic_osyncstream<char> osyncstream;
+#endif
+
+ typedef basic_streambuf<wchar_t> wstreambuf;
+ typedef basic_istream<wchar_t> wistream;
+ typedef basic_ostream<wchar_t> wostream;
+ typedef basic_iostream<wchar_t> wiostream;
+
+ typedef basic_stringbuf<wchar_t> wstringbuf;
+ typedef basic_istringstream<wchar_t> wistringstream;
+ typedef basic_ostringstream<wchar_t> wostringstream;
+ typedef basic_stringstream<wchar_t> wstringstream;
+
+ typedef basic_filebuf<wchar_t> wfilebuf;
+ typedef basic_ifstream<wchar_t> wifstream;
+ typedef basic_ofstream<wchar_t> wofstream;
+ typedef basic_fstream<wchar_t> wfstream;
+
+#if __cplusplus >= 202002L
+ typedef basic_syncbuf<wchar_t> wsyncbuf;
+ typedef basic_osyncstream<wchar_t> wosyncstream;
+#endif
+
+ template<class state> class fpos;
+ typedef fpos<std::mbstate_t> streampos;
+ typedef fpos<std::mbstate_t> wstreampos;
+#if __cplusplus >= 202002L
+ typedef fpos<std::mbstate_t> u8streampos;
+#endif
+#if __cplusplus >= 201103L
+ typedef fpos<std::mbstate_t> u16streampos;
+ typedef fpos<std::mbstate_t> u32streampos;
+#endif
+}
diff --git a/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc b/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc
new file mode 100644
index 00000000000..e2c9c9b8dfa
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/headers/iosfwd/types.cc
@@ -0,0 +1,214 @@
+// { dg-do compile { target c++11 } }
+
+#include <iosfwd>
+
+template<class, class> struct Same { static constexpr bool value = false; };
+template<class T> struct Same<T, T> { static constexpr bool value = true; };
+
+template<class T> using Traits = std::char_traits<T>;
+template<class T> using Alloc = std::allocator<T>;
+
+using std::basic_ios;
+
+static_assert(Same<basic_ios<char>,
+ basic_ios<char, Traits<char>>
+ >::value,
+ "std::basic_ios<char> has the correct default template argument");
+
+static_assert(Same<basic_ios<wchar_t>,
+ basic_ios<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_ios<wchar_t> has the correct default template argument");
+
+using std::basic_streambuf;
+
+static_assert(Same<basic_streambuf<char>,
+ basic_streambuf<char, Traits<char>>
+ >::value,
+ "std::basic_streambuf<char> has the correct default template argument");
+
+static_assert(Same<basic_streambuf<wchar_t>,
+ basic_streambuf<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_streambuf<wchar_t> has the correct default template argument");
+
+using std::basic_istream;
+
+static_assert(Same<basic_istream<char>,
+ basic_istream<char, Traits<char>>
+ >::value,
+ "std::basic_istream<char> has the correct default template argument");
+
+static_assert(Same<basic_istream<wchar_t>,
+ basic_istream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_istream<wchar_t> has the correct default template argument");
+
+using std::basic_ostream;
+
+static_assert(Same<basic_ostream<char>,
+ basic_ostream<char, Traits<char>>
+ >::value,
+ "std::basic_ostream<char> has the correct default template argument");
+
+static_assert(Same<basic_ostream<wchar_t>,
+ basic_ostream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_ostream<wchar_t> has the correct default template argument");
+
+using std::basic_iostream;
+
+static_assert(Same<basic_iostream<char>,
+ basic_iostream<char, Traits<char>>>::value,
+ "std::basic_iostream<char> has the correct default template argument");
+
+static_assert(Same<basic_iostream<wchar_t>,
+ basic_iostream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_iostream<wchar_t> has the correct default template argument");
+
+using std::basic_stringbuf;
+
+static_assert(Same<basic_stringbuf<char>,
+ basic_stringbuf<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_stringbuf<char> has the correct default template argument");
+
+static_assert(Same<basic_stringbuf<wchar_t>,
+ basic_stringbuf<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_stringbuf<wchar_t> has the correct default template argument");
+
+using std::basic_istringstream;
+
+static_assert(Same<basic_istringstream<char>,
+ basic_istringstream<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_istringstream<char> has the correct default template argument");
+
+static_assert(Same<basic_istringstream<wchar_t>,
+ basic_istringstream<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_istringstream<wchar_t> has the correct default template argument");
+
+using std::basic_ostringstream;
+
+static_assert(Same<basic_ostringstream<char>,
+ basic_ostringstream<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_ostringstream<char> has the correct default template argument");
+
+static_assert(Same<basic_ostringstream<wchar_t>,
+ basic_ostringstream<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_ostringstream<wchar_t> has the correct default template argument");
+
+using std::basic_stringstream;
+
+static_assert(Same<basic_stringstream<char>,
+ basic_stringstream<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_stringstream<char> has the correct default template argument");
+
+static_assert(Same<basic_stringstream<wchar_t>,
+ basic_stringstream<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_stringstream<wchar_t> has the correct default template argument");
+
+using std::basic_filebuf;
+
+static_assert(Same<basic_filebuf<char>,
+ basic_filebuf<char, Traits<char>>
+ >::value,
+ "std::basic_filebuf<char> has the correct default template argument");
+
+static_assert(Same<basic_filebuf<wchar_t>,
+ basic_filebuf<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_filebuf<wchar_t> has the correct default template argument");
+
+using std::basic_ifstream;
+
+static_assert(Same<basic_ifstream<char>,
+ basic_ifstream<char, Traits<char>>
+ >::value,
+ "std::basic_ifstream<char> has the correct default template argument");
+
+static_assert(Same<basic_ifstream<wchar_t>,
+ basic_ifstream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_ifstream<wchar_t> has the correct default template argument");
+
+using std::basic_ofstream;
+
+static_assert(Same<basic_ofstream<char>,
+ basic_ofstream<char, Traits<char>>
+ >::value,
+ "std::basic_ofstream<char> has the correct default template argument");
+
+static_assert(Same<basic_ofstream<wchar_t>,
+ basic_ofstream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_ofstream<wchar_t> has the correct default template argument");
+
+using std::basic_fstream;
+
+static_assert(Same<basic_fstream<char>,
+ basic_fstream<char, Traits<char>>
+ >::value,
+ "std::basic_fstream<char> has the correct default template argument");
+
+static_assert(Same<basic_fstream<wchar_t>,
+ basic_fstream<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::basic_fstream<wchar_t> has the correct default template argument");
+
+#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
+using std::basic_syncbuf;
+
+static_assert(Same<basic_syncbuf<char>,
+ basic_syncbuf<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_syncbuf<char> has the correct default template argument");
+
+static_assert(Same<basic_syncbuf<wchar_t>,
+ basic_syncbuf<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_syncbuf<wchar_t> has the correct default template argument");
+
+using std::basic_osyncstream;
+
+static_assert(Same<basic_osyncstream<char>,
+ basic_osyncstream<char, Traits<char>, Alloc<char>>
+ >::value,
+ "std::basic_osyncstream<char> has the correct default template argument");
+
+static_assert(Same<basic_osyncstream<wchar_t>,
+ basic_osyncstream<wchar_t, Traits<wchar_t>, Alloc<wchar_t>>
+ >::value,
+ "std::basic_osyncstream<wchar_t> has the correct default template argument");
+#endif
+
+using std::istreambuf_iterator;
+
+static_assert(Same<istreambuf_iterator<char>,
+ istreambuf_iterator<char, Traits<char>>
+ >::value,
+ "std::istreambuf_iterator<char> has the correct default template argument");
+
+static_assert(Same<istreambuf_iterator<wchar_t>,
+ istreambuf_iterator<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::istreambuf_iterator<wchar_t> has the correct default template argument");
+
+using std::ostreambuf_iterator;
+
+static_assert(Same<ostreambuf_iterator<char>,
+ ostreambuf_iterator<char, Traits<char>>
+ >::value,
+ "std::ostreambuf_iterator<char> has the correct default template argument");
+
+static_assert(Same<ostreambuf_iterator<wchar_t>,
+ ostreambuf_iterator<wchar_t, Traits<wchar_t>>
+ >::value,
+ "std::ostreambuf_iterator<wchar_t> has the correct default template argument");