<iosfwd>ヘッダは、入出力ライブラリ(<ios>、<streambuf>、<istream>、<ostream>、<sstream>、<spanstream>、<fstream>、<syncstream>)で定義されるクラステンプレートおよびそれらの型の別名の、先行宣言(forward declaration)を提供する。
各クラスの完全な定義を必要とせず、宣言のみで十分な場面(関数の宣言や、ポインタ・参照のみを扱うヘッダなど)でこのヘッダをインクルードすることで、実体を定義するヘッダ全体をインクルードするよりもコンパイル時間を短縮できる。
クラステンプレート
| 名前 | 説明 | 対応バージョン |
|---|---|---|
char_traits |
文字特性 (class template) | |
basic_ios |
入出力共通の基底クラス (class template) | |
basic_streambuf |
ストリームバッファ (class template) | |
basic_istream |
入力ストリーム (class template) | |
basic_ostream |
出力ストリーム (class template) | |
basic_iostream |
入出力ストリーム (class template) | |
basic_stringbuf |
文字列ストリームバッファ (class template) | |
basic_istringstream |
入力文字列ストリーム (class template) | |
basic_ostringstream |
出力文字列ストリーム (class template) | |
basic_stringstream |
入出力文字列ストリーム (class template) | |
basic_spanbuf |
std::span上のストリームバッファ (class template) |
C++23 |
basic_ispanstream |
std::span上の入力ストリーム (class template) |
C++23 |
basic_ospanstream |
std::span上の出力ストリーム (class template) |
C++23 |
basic_spanstream |
std::span上の入出力ストリーム (class template) |
C++23 |
basic_filebuf |
ファイルストリームバッファ (class template) | |
basic_ifstream |
入力ファイルストリーム (class template) | |
basic_ofstream |
出力ファイルストリーム (class template) | |
basic_fstream |
入出力ファイルストリーム (class template) | |
basic_syncbuf |
同期化ストリームバッファ (class template) | C++20 |
basic_osyncstream |
同期化出力ストリーム (class template) | C++20 |
istreambuf_iterator |
入力ストリームバッファイテレータ (class template) | |
ostreambuf_iterator |
出力ストリームバッファイテレータ (class template) | |
fpos |
ストリーム上の位置を表現する型 (class template) |
型の別名
char版とwchar_t版の別名が定義される。
| 名前 | 定義 | 対応バージョン |
|---|---|---|
ios / wios |
basic_ios<char> / <wchar_t> |
|
streambuf / wstreambuf |
basic_streambuf<char> / <wchar_t> |
|
istream / wistream |
basic_istream<char> / <wchar_t> |
|
ostream / wostream |
basic_ostream<char> / <wchar_t> |
|
iostream / wiostream |
basic_iostream<char> / <wchar_t> |
|
stringbuf / wstringbuf |
basic_stringbuf<char> / <wchar_t> |
|
istringstream / wistringstream |
basic_istringstream<char> / <wchar_t> |
|
ostringstream / wostringstream |
basic_ostringstream<char> / <wchar_t> |
|
stringstream / wstringstream |
basic_stringstream<char> / <wchar_t> |
|
spanbuf / wspanbuf |
basic_spanbuf<char> / <wchar_t> |
C++23 |
ispanstream / wispanstream |
basic_ispanstream<char> / <wchar_t> |
C++23 |
ospanstream / wospanstream |
basic_ospanstream<char> / <wchar_t> |
C++23 |
spanstream / wspanstream |
basic_spanstream<char> / <wchar_t> |
C++23 |
filebuf / wfilebuf |
basic_filebuf<char> / <wchar_t> |
|
ifstream / wifstream |
basic_ifstream<char> / <wchar_t> |
|
ofstream / wofstream |
basic_ofstream<char> / <wchar_t> |
|
fstream / wfstream |
basic_fstream<char> / <wchar_t> |
|
syncbuf / wsyncbuf |
basic_syncbuf<char> / <wchar_t> |
C++20 |
osyncstream / wosyncstream |
basic_osyncstream<char> / <wchar_t> |
C++20 |
streampos |
fpos<char_traits<char>::state_type> |
|
wstreampos |
fpos<char_traits<wchar_t>::state_type> |
|
u8streampos |
fpos<char_traits<char8_t>::state_type> |
C++20 |
u16streampos |
fpos<char_traits<char16_t>::state_type> |
C++11 |
u32streampos |
fpos<char_traits<char32_t>::state_type> |
C++11 |
備考
- このヘッダは、上記の型のデフォルトテンプレート引数を含んだ宣言を提供する。同じ既定引数は各実体定義ヘッダにも現れるが、
<iosfwd>とそれらのヘッダを同時にインクルードしても適格である。
バージョン
言語
- C++98
関連項目
参照
- LWG Issue 4440. Forward declarations of entities need also in entries
- C++26で、
__cpp_lib_char8_t・__cpp_lib_spanstream・__cpp_lib_syncbufの機能テストマクロの定義ヘッダに<iosfwd>が追加された(<iosfwd>がこれらに関連するエンティティの先行宣言を含むため)
- C++26で、