1// <iosfwd> Forward declarations -*- C++ -*-
3// Copyright (C) 1997-2023 Free Software Foundation, Inc.
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
25/** @file include/iosfwd
26 * This is a Standard C++ Library header.
30// ISO C++ 14882: 27.2 Forward declarations
33#ifndef _GLIBCXX_IOSFWD
34#define _GLIBCXX_IOSFWD 1
36#pragma GCC system_header
38#include <bits/requires_hosted.h> // iostreams
40#include <bits/c++config.h>
41#include <bits/stringfwd.h> // For string forward declarations.
42#include <bits/postypes.h>
44namespace std _GLIBCXX_VISIBILITY(default)
46_GLIBCXX_BEGIN_NAMESPACE_VERSION
51 * Nearly all of the I/O classes are parameterized on the type of
52 * characters they read and write. (The major exception is ios_base at
53 * the top of the hierarchy.) This is a change from pre-Standard
54 * streams, which were not templates.
56 * For ease of use and compatibility, all of the basic_* I/O-related
57 * classes are given typedef names for both of the builtin character
58 * widths (wide and narrow). The typedefs are the same as the
59 * pre-Standard names, for example:
62 * typedef basic_ifstream<char> ifstream;
65 * Because properly forward-declaring these classes can be difficult, you
66 * should not do it yourself. Instead, include the <iosfwd>
67 * header, which contains only declarations of all the I/O classes as
68 * well as the typedefs. Trying to forward-declare the typedefs
69 * themselves (e.g., <code>class ostream;</code>) is not valid ISO C++.
71 * For more specific declarations, see
72 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects
78 template<typename _CharT, typename _Traits = char_traits<_CharT> >
81 template<typename _CharT, typename _Traits = char_traits<_CharT> >
82 class basic_streambuf;
84 template<typename _CharT, typename _Traits = char_traits<_CharT> >
87 template<typename _CharT, typename _Traits = char_traits<_CharT> >
90 template<typename _CharT, typename _Traits = char_traits<_CharT> >
94_GLIBCXX_BEGIN_NAMESPACE_CXX11
96 template<typename _CharT, typename _Traits = char_traits<_CharT>,
97 typename _Alloc = allocator<_CharT> >
98 class basic_stringbuf;
100 template<typename _CharT, typename _Traits = char_traits<_CharT>,
101 typename _Alloc = allocator<_CharT> >
102 class basic_istringstream;
104 template<typename _CharT, typename _Traits = char_traits<_CharT>,
105 typename _Alloc = allocator<_CharT> >
106 class basic_ostringstream;
108 template<typename _CharT, typename _Traits = char_traits<_CharT>,
109 typename _Alloc = allocator<_CharT> >
110 class basic_stringstream;
112_GLIBCXX_END_NAMESPACE_CXX11
114 template<typename _CharT, typename _Traits = char_traits<_CharT> >
117 template<typename _CharT, typename _Traits = char_traits<_CharT> >
118 class basic_ifstream;
120 template<typename _CharT, typename _Traits = char_traits<_CharT> >
121 class basic_ofstream;
123 template<typename _CharT, typename _Traits = char_traits<_CharT> >
126 template<typename _CharT, typename _Traits = char_traits<_CharT> >
127 class istreambuf_iterator;
129 template<typename _CharT, typename _Traits = char_traits<_CharT> >
130 class ostreambuf_iterator;
133 /// Base class for @c char streams.
134 typedef basic_ios<char> ios;
136 /// Base class for @c char buffers.
137 typedef basic_streambuf<char> streambuf;
139 /// Base class for @c char input streams.
140 typedef basic_istream<char> istream;
142 /// Base class for @c char output streams.
143 typedef basic_ostream<char> ostream;
145 /// Base class for @c char mixed input and output streams.
146 typedef basic_iostream<char> iostream;
148 /// Class for @c char memory buffers.
149 typedef basic_stringbuf<char> stringbuf;
151 /// Class for @c char input memory streams.
152 typedef basic_istringstream<char> istringstream;
154 /// Class for @c char output memory streams.
155 typedef basic_ostringstream<char> ostringstream;
157 /// Class for @c char mixed input and output memory streams.
158 typedef basic_stringstream<char> stringstream;
160 /// Class for @c char file buffers.
161 typedef basic_filebuf<char> filebuf;
163 /// Class for @c char input file streams.
164 typedef basic_ifstream<char> ifstream;
166 /// Class for @c char output file streams.
167 typedef basic_ofstream<char> ofstream;
169 /// Class for @c char mixed input and output file streams.
170 typedef basic_fstream<char> fstream;
172#ifdef _GLIBCXX_USE_WCHAR_T
173 /// Base class for @c wchar_t streams.
174 typedef basic_ios<wchar_t> wios;
176 /// Base class for @c wchar_t buffers.
177 typedef basic_streambuf<wchar_t> wstreambuf;
179 /// Base class for @c wchar_t input streams.
180 typedef basic_istream<wchar_t> wistream;
182 /// Base class for @c wchar_t output streams.
183 typedef basic_ostream<wchar_t> wostream;
185 /// Base class for @c wchar_t mixed input and output streams.
186 typedef basic_iostream<wchar_t> wiostream;
188 /// Class for @c wchar_t memory buffers.
189 typedef basic_stringbuf<wchar_t> wstringbuf;
191 /// Class for @c wchar_t input memory streams.
192 typedef basic_istringstream<wchar_t> wistringstream;
194 /// Class for @c wchar_t output memory streams.
195 typedef basic_ostringstream<wchar_t> wostringstream;
197 /// Class for @c wchar_t mixed input and output memory streams.
198 typedef basic_stringstream<wchar_t> wstringstream;
200 /// Class for @c wchar_t file buffers.
201 typedef basic_filebuf<wchar_t> wfilebuf;
203 /// Class for @c wchar_t input file streams.
204 typedef basic_ifstream<wchar_t> wifstream;
206 /// Class for @c wchar_t output file streams.
207 typedef basic_ofstream<wchar_t> wofstream;
209 /// Class for @c wchar_t mixed input and output file streams.
210 typedef basic_fstream<wchar_t> wfstream;
213#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
214 template<typename _CharT, typename _Traits = char_traits<_CharT>,
215 typename _Allocator = allocator<_CharT>>
217 template<typename _CharT, typename _Traits = char_traits<_CharT>,
218 typename _Allocator = allocator<_CharT>>
219 class basic_osyncstream;
221 using syncbuf = basic_syncbuf<char>;
222 using osyncstream = basic_osyncstream<char>;
224#ifdef _GLIBCXX_USE_WCHAR_T
225 using wsyncbuf = basic_syncbuf<wchar_t>;
226 using wosyncstream = basic_osyncstream<wchar_t>;
228#endif // C++20 && CXX11_ABI
230#if __cplusplus > 202002L
231 template<typename _CharT, typename _Traits = char_traits<_CharT>>
233 template<typename _CharT, typename _Traits = char_traits<_CharT>>
234 class basic_ispanstream;
235 template<typename _CharT, typename _Traits = char_traits<_CharT>>
236 class basic_ospanstream;
237 template<typename _CharT, typename _Traits = char_traits<_CharT>>
238 class basic_spanstream;
240 using spanbuf = basic_spanbuf<char>;
241 using ispanstream = basic_ispanstream<char>;
242 using ospanstream = basic_ospanstream<char>;
243 using spanstream = basic_spanstream<char>;
245#ifdef _GLIBCXX_USE_WCHAR_T
246 using wspanbuf = basic_spanbuf<wchar_t>;
247 using wispanstream = basic_ispanstream<wchar_t>;
248 using wospanstream = basic_ospanstream<wchar_t>;
249 using wspanstream = basic_spanstream<wchar_t>;
255_GLIBCXX_END_NAMESPACE_VERSION
258#endif /* _GLIBCXX_IOSFWD */