Assigns initial values to the components of its base classes by calling the inherited member basic_ios::init with sb as argument.
(2) copy constructor (deleted)
Deleted: no copy constructor.
(3) move constructor (protected)
Acquires the contents of x, except its associated stream buffer: It copies x's gcount value and then calls basic_ios::move to transfer x's basic_ios components. x is left with a gcount value of zero, not tied, and with its associated stream buffer unchanged (all other components of x are in an unspecified but valid state after the call).
Parameters
sb
pointer to a basic_streambuf object with the same template parameters as the basic_istream object. char_type and traits_type are member types defined as aliases of the first and second class template parameters, respectively (see basic_istream types).
x
Another basic_istream of the same type (with the same class template arguments charT and traits).
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// istream constructor
#include <iostream> // std::ios, std::istream, std::cout
#include <fstream> // std::filebuf
int main () {
std::filebuf fb;
if (fb.open ("test.txt",std::ios::in))
{
std::istream is(&fb);
while (is)
std::cout << char(is.get());
fb.close();
}
return 0;
}
This example code uses a basic_filebuf object (derived from basic_streambuf) to open a file called test.txt. The buffer is passed as parameter to the constructor of the basic_istream object is, associating it to the stream. Then, the program uses the input stream to print its contents to cout.