libstdc++
iosfwd
Go to the documentation of this file.
1// <iosfwd> Forward declarations -*- C++ -*-
2
3// Copyright (C) 1997-2025 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#ifdef _GLIBCXX_SYSHDR
37#pragma GCC system_header
38#endif
39
40#include <bits/requires_hosted.h> // iostreams
41
42#include <bits/c++config.h>
43#include <bits/stringfwd.h> // For string forward declarations.
44#include <bits/postypes.h>
45
46namespace std _GLIBCXX_VISIBILITY(default)
47{
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
49
50 /**
51 * @defgroup io I/O
52 *
53 * Nearly all of the I/O classes are parameterized on the type of
54 * characters they read and write. (The major exception is ios_base at
55 * the top of the hierarchy.) This is a change from pre-Standard
56 * streams, which were not templates.
57 *
58 * For ease of use and compatibility, all of the basic_* I/O-related
59 * classes are given typedef names for both of the builtin character
60 * widths (wide and narrow). The typedefs are the same as the
61 * pre-Standard names, for example:
62 *
63 * @code
64 * typedef basic_ifstream<char> ifstream;
65 * @endcode
66 *
67 * Because properly forward-declaring these classes can be difficult, you
68 * should not do it yourself. Instead, include the &lt;iosfwd&gt;
69 * header, which contains only declarations of all the I/O classes as
70 * well as the typedefs. Trying to forward-declare the typedefs
71 * themselves (e.g., <code>class ostream;</code>) is not valid ISO C++.
72 *
73 * For more specific declarations, see
74 * https://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html#std.io.objects
75 *
76 * @{
77 */
78 class ios_base;
79
80 template<typename _CharT, typename _Traits = char_traits<_CharT> >
81 class basic_ios;
82
83 template<typename _CharT, typename _Traits = char_traits<_CharT> >
84 class basic_streambuf;
85
86 template<typename _CharT, typename _Traits = char_traits<_CharT> >
87 class basic_istream;
88
89 template<typename _CharT, typename _Traits = char_traits<_CharT> >
90 class basic_ostream;
91
92 template<typename _CharT, typename _Traits = char_traits<_CharT> >
93 class basic_iostream;
94
95
96_GLIBCXX_BEGIN_NAMESPACE_CXX11
97
98 template<typename _CharT, typename _Traits = char_traits<_CharT>,
99 typename _Alloc = allocator<_CharT> >
100 class basic_stringbuf;
101
102 template<typename _CharT, typename _Traits = char_traits<_CharT>,
103 typename _Alloc = allocator<_CharT> >
104 class basic_istringstream;
105
106 template<typename _CharT, typename _Traits = char_traits<_CharT>,
107 typename _Alloc = allocator<_CharT> >
108 class basic_ostringstream;
109
110 template<typename _CharT, typename _Traits = char_traits<_CharT>,
111 typename _Alloc = allocator<_CharT> >
112 class basic_stringstream;
113
114_GLIBCXX_END_NAMESPACE_CXX11
115
116 template<typename _CharT, typename _Traits = char_traits<_CharT> >
117 class basic_filebuf;
118
119 template<typename _CharT, typename _Traits = char_traits<_CharT> >
120 class basic_ifstream;
121
122 template<typename _CharT, typename _Traits = char_traits<_CharT> >
123 class basic_ofstream;
124
125 template<typename _CharT, typename _Traits = char_traits<_CharT> >
126 class basic_fstream;
127
128 template<typename _CharT, typename _Traits = char_traits<_CharT> >
129 class istreambuf_iterator;
130
131 template<typename _CharT, typename _Traits = char_traits<_CharT> >
132 class ostreambuf_iterator;
133
134
135 /// Base class for @c char streams.
137
138 /// Base class for @c char buffers.
140
141 /// Base class for @c char input streams.
143
144 /// Base class for @c char output streams.
146
147 /// Base class for @c char mixed input and output streams.
149
150 /// Class for @c char memory buffers.
152
153 /// Class for @c char input memory streams.
155
156 /// Class for @c char output memory streams.
158
159 /// Class for @c char mixed input and output memory streams.
161
162 /// Class for @c char file buffers.
164
165 /// Class for @c char input file streams.
167
168 /// Class for @c char output file streams.
170
171 /// Class for @c char mixed input and output file streams.
173
174#ifdef _GLIBCXX_USE_WCHAR_T
175 /// Base class for @c wchar_t streams.
177
178 /// Base class for @c wchar_t buffers.
180
181 /// Base class for @c wchar_t input streams.
183
184 /// Base class for @c wchar_t output streams.
186
187 /// Base class for @c wchar_t mixed input and output streams.
189
190 /// Class for @c wchar_t memory buffers.
192
193 /// Class for @c wchar_t input memory streams.
195
196 /// Class for @c wchar_t output memory streams.
198
199 /// Class for @c wchar_t mixed input and output memory streams.
201
202 /// Class for @c wchar_t file buffers.
204
205 /// Class for @c wchar_t input file streams.
207
208 /// Class for @c wchar_t output file streams.
210
211 /// Class for @c wchar_t mixed input and output file streams.
213#endif
214
215#if __cplusplus >= 202002L && _GLIBCXX_USE_CXX11_ABI
216 template<typename _CharT, typename _Traits = char_traits<_CharT>,
217 typename _Allocator = allocator<_CharT>>
218 class basic_syncbuf;
219 template<typename _CharT, typename _Traits = char_traits<_CharT>,
220 typename _Allocator = allocator<_CharT>>
221 class basic_osyncstream;
222
223 using syncbuf = basic_syncbuf<char>;
224 using osyncstream = basic_osyncstream<char>;
225
226#ifdef _GLIBCXX_USE_WCHAR_T
227 using wsyncbuf = basic_syncbuf<wchar_t>;
228 using wosyncstream = basic_osyncstream<wchar_t>;
229#endif
230#endif // C++20 && CXX11_ABI
231
232#if __cplusplus > 202002L
233 template<typename _CharT, typename _Traits = char_traits<_CharT>>
234 class basic_spanbuf;
235 template<typename _CharT, typename _Traits = char_traits<_CharT>>
236 class basic_ispanstream;
237 template<typename _CharT, typename _Traits = char_traits<_CharT>>
238 class basic_ospanstream;
239 template<typename _CharT, typename _Traits = char_traits<_CharT>>
240 class basic_spanstream;
241
242 using spanbuf = basic_spanbuf<char>;
243 using ispanstream = basic_ispanstream<char>;
244 using ospanstream = basic_ospanstream<char>;
245 using spanstream = basic_spanstream<char>;
246
247#ifdef _GLIBCXX_USE_WCHAR_T
248 using wspanbuf = basic_spanbuf<wchar_t>;
249 using wispanstream = basic_ispanstream<wchar_t>;
250 using wospanstream = basic_ospanstream<wchar_t>;
251 using wspanstream = basic_spanstream<wchar_t>;
252#endif
253#endif // C++23
254
255 /** @} */
256
257_GLIBCXX_END_NAMESPACE_VERSION
258} // namespace
259
260#endif /* _GLIBCXX_IOSFWD */
basic_ifstream< wchar_t > wifstream
Class for wchar_t input file streams.
Definition iosfwd:206
basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition iosfwd:160
basic_iostream< wchar_t > wiostream
Base class for wchar_t mixed input and output streams.
Definition iosfwd:188
basic_streambuf< char > streambuf
Base class for char buffers.
Definition iosfwd:139
basic_stringbuf< wchar_t > wstringbuf
Class for wchar_t memory buffers.
Definition iosfwd:191
basic_ostream< char > ostream
Base class for char output streams.
Definition iosfwd:145
basic_ifstream< char > ifstream
Class for char input file streams.
Definition iosfwd:166
basic_iostream< char > iostream
Base class for char mixed input and output streams.
Definition iosfwd:148
basic_ios< wchar_t > wios
Base class for wchar_t streams.
Definition iosfwd:176
basic_istringstream< char > istringstream
Class for char input memory streams.
Definition iosfwd:154
basic_streambuf< wchar_t > wstreambuf
Base class for wchar_t buffers.
Definition iosfwd:179
basic_istringstream< wchar_t > wistringstream
Class for wchar_t input memory streams.
Definition iosfwd:194
basic_fstream< wchar_t > wfstream
Class for wchar_t mixed input and output file streams.
Definition iosfwd:212
basic_ofstream< char > ofstream
Class for char output file streams.
Definition iosfwd:169
basic_ostringstream< wchar_t > wostringstream
Class for wchar_t output memory streams.
Definition iosfwd:197
basic_istream< char > istream
Base class for char input streams.
Definition iosfwd:142
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
Definition iosfwd:185
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
Definition iosfwd:182
basic_filebuf< char > filebuf
Class for char file buffers.
Definition iosfwd:163
basic_filebuf< wchar_t > wfilebuf
Class for wchar_t file buffers.
Definition iosfwd:203
basic_ofstream< wchar_t > wofstream
Class for wchar_t output file streams.
Definition iosfwd:209
basic_fstream< char > fstream
Class for char mixed input and output file streams.
Definition iosfwd:172
basic_stringstream< wchar_t > wstringstream
Class for wchar_t mixed input and output memory streams.
Definition iosfwd:200
basic_ios< char > ios
Base class for char streams.
Definition iosfwd:136
basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition iosfwd:157
basic_stringbuf< char > stringbuf
Class for char memory buffers.
Definition iosfwd:151
ISO C++ entities toplevel namespace is std.
The actual work of input and output (for files).
Definition fstream:93
Controlling input for files.
Definition fstream:536
Controlling output for files.
Definition fstream:809
Controlling input and output for files.
Definition fstream:1084
Template class basic_ios, virtual base class for all stream classes.
Definition basic_ios.h:70
The actual work of input and output (interface).
Definition streambuf:127
Template class basic_istream.
Definition istream:63
Template class basic_ostream.
Definition ostream:69
Template class basic_iostream.
Definition istream:988
The actual work of input and output (for std::string).
Definition sstream:82
Controlling input for std::string.
Definition sstream:553
Controlling output for std::string.
Definition sstream:781
Controlling input and output for std::string.
Definition sstream:1009