std::basic_fstream
From cppreference.com
| Defined in header <fstream>
|
||
| template< class CharT, |
||
The class template basic_fstream implements high-level input/output operations on file based streams. It interfaces a file-based streambuffer (std::basic_filebuf) with the high-level interface of (std::basic_iostream).
A typical implementation of std::basic_fstream holds only one non-derived data member: an instance of std::basic_filebuf<CharT, Traits>.
Inheritance diagram
Several typedefs for common character types are provided:
| Defined in header
<fstream> | |
| Type | Definition |
std::fstream
|
std::basic_fstream<char> |
std::wfstream
|
std::basic_fstream<wchar_t> |
Contents |
[edit] Member types
| Member type | Definition |
char_type
|
CharT
|
traits_type
|
Traits; the program is ill-formed if Traits::char_type is not CharT.
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
native_handle_type(C++26)
|
implementation-defined type that is TriviallyCopyable and semiregular
|
[edit] Member functions
| constructs the file stream (public member function) | |
| (destructor) [virtual] (implicitly declared) |
destructs the basic_fstream and the associated buffer, closes the file (virtual public member function) |
| (C++11) |
moves the file stream (public member function) |
| (C++11) |
swaps two file streams (public member function) |
| returns the underlying raw file device object (public member function) | |
| (C++26) |
returns the underlying implementation-defined handle (public member function) |
File operations | |
| checks if the stream has an associated file (public member function) | |
| opens a file and associates it with the stream (public member function) | |
| closes the associated file (public member function) | |
[edit] Non-member functions
| specializes the std::swap algorithm (function template) |
Inherited from std::basic_istream
Member functions
Formatted input | |
| extracts formatted data (public member function of std::basic_istream<CharT,Traits>)
| |
Unformatted input | |
| extracts characters (public member function of std::basic_istream<CharT,Traits>)
| |
| reads the next character without extracting it (public member function of std::basic_istream<CharT,Traits>)
| |
| unextracts a character (public member function of std::basic_istream<CharT,Traits>)
| |
| puts a character into input stream (public member function of std::basic_istream<CharT,Traits>)
| |
| extracts characters until the given character is found (public member function of std::basic_istream<CharT,Traits>)
| |
| extracts and discards characters until the given character is found (public member function of std::basic_istream<CharT,Traits>)
| |
| extracts blocks of characters (public member function of std::basic_istream<CharT,Traits>)
| |
| extracts already available blocks of characters (public member function of std::basic_istream<CharT,Traits>)
| |
| returns number of characters extracted by last unformatted input operation (public member function of std::basic_istream<CharT,Traits>)
| |
Positioning | |
| returns the input position indicator (public member function of std::basic_istream<CharT,Traits>)
| |
| sets the input position indicator (public member function of std::basic_istream<CharT,Traits>)
| |
Miscellaneous | |
| synchronizes with the underlying storage device (public member function of std::basic_istream<CharT,Traits>) | |