std::basic_istream::basic_istream

来自cppreference.com
< cpp‎ | io‎ | basic istream

explicit basic_istream( std::basic_streambuf<CharT,Traits>* sb);
(1)
protected:
basic_istream( const basic_istream& rhs ) = delete;
(2)
protected:
basic_istream( basic_istream&& rhs );
(3) (C++11 起)
1)
,分配初始值basic_istream通过调用基类的构造basic_ios::init(sb)对象。被初始化为零的值gcount().
原文:
Constructs the basic_istream object, assigning initial values to the base class by calling basic_ios::init(sb). The value of gcount() is initialized to zero.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
2)
拷贝构造函数是受保护的,将被删除。输入流是不可复制的.
原文:
The copy constructor is protected, and is deleted. Input streams are not copyable.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
3)
此举构造函数的值复制gcount()rhs的gcount的(),设定值的右边为零,并使用basic_ios<charT, traits>::move(rhs),将所有basic_ios的成员,除为rdbuf(),从rhs*this。这一举动的构造函数是受保护的,它被称为可移动的输入流类的构造函数的移动std::basic_ifstreamstd::basic_istringstream,哪知道如何正确地移动相关的streambuffer的.
原文:
The move constructor copies the value of gcount() from rhs, sets the gcount() value of rhs to zero, and uses basic_ios<charT, traits>::move(rhs) to move all basic_ios members, except for the rdbuf(), from rhs into *this. This move constructor is protected: it is called by the move constructors of movable input stream classes std::basic_ifstream and std::basic_istringstream, which know how to correctly move the associated streambuffer.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 参数

sb -
streambuffer使用的基础设备
原文:
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