Defined in the header file <istream>
template< class CharT, |
Class templates basic_iostream
provide high-level input/output support on streams. Supported operations include read or write and format. This functionality basic_streambuf
is provided by the class and implemented on the interface. Buffers are accessed through basic_ios
the class.
inheritance diagram
Two specializations are defined for common character types:
defined in the header file |
|
type | definition |
iostream |
basic_iostream<char> |
wiostream |
basic_iostream<wchar_t> |
member function
construct object
std::basic_iostream<CharT,Traits>::basic_iostream
explicit basic_iostream( std::basic_streambuf<CharT,Traits>* sb ); |
(1) | |
basic_iostream( const basic_iostream& other ) = delete; |
(2) | (since C++11) |
protected: |
(3) | (since C++11) |
Constructs a new stream object.
sb
1) Initialize with streambuf . The base classes are initialized as basic_istream<CharT,Traits>(sb) and basic_ostream<CharT,Traits>(sb). After calling rdbuf() == sb and gcount() == 0.
2) Copy construction is not allowed.
3) Move constructor: The first base class of move construction basic_istream
is basic_istream<CharT,Traits>(std::move(rhs)); This will continue the move construction and initialize the virtual base class std::basic_ios. The initialization of another base class basic_ostream
is implementation-defined (eg, a protected default constructor that does nothing can be added to std::basic_ostream), since move construction cannot be used rhs
twice. This move constructor is protected: it is called by the move constructors of the derived stream classes std::basic_fstream and std::basic_stringstream before they are moved and associated with the stream buffer.
parameter
sb | - | The streambuf to initialize |
other | - | Another stream to initialize |
destructor object
std::basic_iostream<CharT,Traits>::~basic_iostream
virtual ~basic_iostream(); |
Destructs an input/output stream.
Notice
This destructor does not rdbuf()
perform any operations on the underlying stream buffer ( ): the destructors of exported streams such as std::basic_fstream and std::basic_stringstream are responsible for calling the stream buffer's destructor.
protected member function
Move assignment to another basic_iostream
std::basic_iostream<CharT,Traits>::operator=
basic_iostream& operator=( const basic_iostream& other ) = delete; |
(1) | |
protected: |
(2) | (since C++11) |
Assign another stream object.
1) Copy assignment is not allowed.
2) Move assignment to another stream object. Equivalently calls swap(rhs). This move assignment operator is protected: it is invoked by the move assignment operators of the derived stream classes std::basic_stringstream and std::basic_fstream, which know how to properly move the associated stream buffer.
parameter
other | - | another stream whose state is to be assigned |
return value
*this
Exchange state with another basic_iostream
std::basic_iostream<CharT,Traits>::swap
protected: |
(since C++11) |
Exchange state with another input/output stream. Equivalently calls basic_istream<CharT,Traits>::swap(other) .
This member function is protected: the swap member function of the exported stream classes std::basic_stringstream and std::basic_fstream knows how to properly swap the associated buffer and calls this function.
parameter
other | - | another stream to exchange state with |
return value
*this