1// <iosfwd> Forward declarations -*- C++ -*-
2
3// Copyright (C) 1997-2024 Free Software Foundation, Inc.
4//
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)
9// any later version.
10
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.
15
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.
19
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/>.
24
25/** @file include/iosfwd
26 * This is a Standard C++ Library header.
27 */
28
29//
30// ISO C++ 14882: 27.2 Forward declarations
31//
32
33#ifndef _GLIBCXX_IOSFWD
34#define _GLIBCXX_IOSFWD 1
35
36#pragma GCC system_header
37
38#include <bits/requires_hosted.h> // iostreams
39
40#include <bits/c++config.h>
41#include <bits/stringfwd.h> // For string forward declarations.
42#include <bits/postypes.h>
43
44namespace std _GLIBCXX_VISIBILITY(default)
45{
46_GLIBCXX_BEGIN_NAMESPACE_VERSION
47
48 /**
49 * @defgroup io I/O
50 *
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.
55 *
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:
60 *
61 * @code
62 * typedef basic_ifstream<char> ifstream;
63 * @endcode
64 *
65 * Because properly forward-declaring these classes can be difficult, you
66 * should not do it yourself. Instead, include the &lt;iosfwd&gt;
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++.
70 *
71 * For more specific declarations, see
72 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects
73 *
74 * @{
75 */
76 class ios_base;
77
78 template<typename _CharT, typename _Traits = char_traits<_CharT> >
79 class basic_ios;
80
81 template<typename _CharT, typename _Traits = char_traits<_CharT> >
82 class basic_streambuf;
83
84 template<typename _CharT, typename _Traits = char_traits<_CharT> >
85 class basic_istream;
86
87 template<typename _CharT, typename _Traits = char_traits<_CharT> >
88 class basic_ostream;
89
90 template<typename _CharT, typename _Traits = char_traits<_CharT> >
91 class basic_iostream;
92
93
94_GLIBCXX_BEGIN_NAMESPACE_CXX11
95
96 template<typename _CharT, typename _Traits = char_traits<_CharT>,
97 typename _Alloc = allocator<_CharT> >
98 class basic_stringbuf;
99
100 template<typename _CharT, typename _Traits = char_traits<_CharT>,
101 typename _Alloc = allocator<_CharT> >
102 class basic_istringstream;
103
104 template<typename _CharT, typename _Traits = char_traits<_CharT>,
105 typename _Alloc = allocator<_CharT> >
106 class basic_ostringstream;
107
108 template<typename _CharT, typename _Traits = char_traits<_CharT>,
109 typename _Alloc = allocator<_CharT> >
110 class basic_stringstream;
111
112_GLIBCXX_END_NAMESPACE_CXX11
113
114 template<typename _CharT, typename _Traits = char_traits<_CharT> >
115 class basic_filebuf;
116
117 template<typename _CharT, typename _Traits = char_traits<_CharT> >
118 class basic_ifstream;
119
120 template<typename _CharT, typename _Traits = char_traits<_CharT> >
121 class basic_ofstream;
122
123 template<typename _CharT, typename _Traits = char_traits<_CharT> >
124 class basic_fstream;
125
126 template<typename _CharT, typename _Traits = char_traits<_CharT> >
127 class istreambuf_iterator;
128
129 template<typename _CharT, typename _Traits = char_traits<_CharT> >
130 class ostreambuf_iterator;
131
132
133 /// Base class for @c char streams.
134 typedef basic_ios<char> ios;
135
136 /// Base class for @c char buffers.
137 typedef basic_streambuf<char> streambuf;
138
139 /// Base class for @c char input streams.
140 typedef basic_istream<char> istream;
141
142 /// Base class for @c char output streams.
143 typedef basic_ostream<char> ostream;
144
145 /// Base class for @c char mixed input and output streams.
146 typedef basic_iostream<char> iostream;
147
148 /// Class for @c char memory buffers.
149 typedef basic_stringbuf<char> stringbuf;
150
151 /// Class for @c char input memory streams.
152 typedef basic_istringstream<char> istringstream;
153
154 /// Class for @c char output memory streams.
155 typedef basic_ostringstream<char> ostringstream;
156
157 /// Class for @c char mixed input and output memory streams.
158 typedef basic_stringstream<char> stringstream;
159
160 /// Class for @c char file buffers.
161 typedef basic_filebuf<char> filebuf;
162
163 /// Class for @c char input file streams.
164 typedef basic_ifstream<char> ifstream;
165
166 /// Class for @c char output file streams.
167 typedef basic_ofstream<char> ofstream;
168
169 /// Class for @c char mixed input and output file streams.
170 typedef basic_fstream<char> fstream;
171
172#ifdef _GLIBCXX_USE_WCHAR_T
173 /// Base class for @c wchar_t streams.
174 typedef basic_ios<wchar_t> wios;
175
176 /// Base class for @c wchar_t buffers.
177 typedef basic_streambuf<wchar_t> wstreambuf;
178
179 /// Base class for @c wchar_t input streams.
180 typedef basic_istream<wchar_t> wistream;
181
182 /// Base class for @c wchar_t output streams.
183 typedef basic_ostream<wchar_t> wostream;
184
185 /// Base class for @c wchar_t mixed input and output streams.
186 typedef basic_iostream<wchar_t> wiostream;
187
188 /// Class for @c wchar_t memory buffers.
189 typedef basic_stringbuf<wchar_t> wstringbuf;
190
191 /// Class for @c wchar_t input memory streams.
192 typedef basic_istringstream<wchar_t> wistringstream;
193
194 /// Class for @c wchar_t output memory streams.
195 typedef basic_ostringstream<wchar_t> wostringstream;
196
197 /// Class for @c wchar_t mixed input and output memory streams.
198 typedef basic_stringstream<wchar_t> wstringstream;
199
200 /// Class for @c wchar_t file buffers.
201 typedef basic_filebuf<wchar_t> wfilebuf;
202
203 /// Class for @c wchar_t input file streams.
204 typedef basic_ifstream<wchar_t> wifstream;
205
206 /// Class for @c wchar_t output file streams.
207 typedef basic_ofstream<wchar_t> wofstream;
208
209 /// Class for @c wchar_t mixed input and output file streams.
210 typedef basic_fstream<wchar_t> wfstream;
211#endif
212
213#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
214 template<typename _CharT, typename _Traits = char_traits<_CharT>,
215 typename _Allocator = allocator<_CharT>>
216 class basic_syncbuf;
217 template<typename _CharT, typename _Traits = char_traits<_CharT>,
218 typename _Allocator = allocator<_CharT>>
219 class basic_osyncstream;
220
221 using syncbuf = basic_syncbuf<char>;
222 using osyncstream = basic_osyncstream<char>;
223
224#ifdef _GLIBCXX_USE_WCHAR_T
225 using wsyncbuf = basic_syncbuf<wchar_t>;
226 using wosyncstream = basic_osyncstream<wchar_t>;
227#endif
228#endif // C++20 && CXX11_ABI
229
230#if __cplusplus > 202002L
231 template<typename _CharT, typename _Traits = char_traits<_CharT>>
232 class basic_spanbuf;
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;
239
240 using spanbuf = basic_spanbuf<char>;
241 using ispanstream = basic_ispanstream<char>;
242 using ospanstream = basic_ospanstream<char>;
243 using spanstream = basic_spanstream<char>;
244
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>;
250#endif
251#endif // C++23
252
253 /** @} */
254
255_GLIBCXX_END_NAMESPACE_VERSION
256} // namespace
257
258#endif /* _GLIBCXX_IOSFWD */
259