std::basic_istream::basic_istream
性病:基本[医]iStream::Basic[医]iStream
explicit basic_istream( std::basic_streambuf | (1) | |
---|---|---|
protected: basic_istream( const basic_istream& rhs ) = delete; | (2) | (since C++11) |
protected: basic_istream( basic_istream&& rhs | (3) | (since C++11) |
1%29构造basic_istream
对象,通过调用basic_ios::init(sb)
.的价值gcount()
初始化为零。
2%29复制构造函数受到保护,并被删除。输入流不可复制。
3%29移动构造函数复制gcount()从rhs,将rhs的gcount%28%29值设置为零,并使用basic_ios<CharT, Traits>::move(rhs)移动所有基本的[医]IOS成员,除rdbuf(),来自rhs进*this这个移动构造函数是受保护的:它由可移动输入流类的移动构造函数调用。std::basic_ifstream和std::basic_istringstream,它们知道如何正确移动关联的流缓冲区。
参数
sb | - | streambuffer to use as underlying device |
---|
例
二次
#include <sstream>
#include <iostream>
int main()
{
std::istringstream s1("hello"
std::istream s2(s1.rdbuf() // OK: s2 shares the buffer with s1
// std::istream s3(std::istringstream("test") // ERROR: move constructor is protected
// std::istream s4(s2 // ERROR: copy constructor is deleted
std::istringstream s5(std::istringstream("world") // OK: move ctor called by derived class
std::cout << s2.rdbuf() << ' ' << s5.rdbuf() << '\n';
}
二次
产出:
二次
hello world
二次
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
http://en.cppreference.com/w/cpp/io/basic[医]iStream/Basic[医]iStream