在线文档教程
C++
输入/输出 | Input/output

std::basic_ostream::basic_ostream

性病:基本[医]Ostream::Basic[医]流

explicit basic_ostream( std::basic_streambuf* sb (1)
protected: basic_ostream( const basic_ostream& rhs ) = delete;(2)(since C++11)
protected: basic_ostream( basic_ostream&& rhs (3)(since C++11)

1%29构造basic_ostream对象,通过调用basic_ios::init(sb)...

2%29复制构造函数受到保护,并被删除。输出流不可复制。

3%29移动构造函数使用basic_ios<CharT, Traits>::move(rhs)移动所有基本的[医]IOS成员,除rdbuf(),来自rhs进*this这个移动构造函数是受保护的:它由可移动输出流类的移动构造函数调用。std::basic_ofstream和std::basic_ostringstream,它们知道如何正确移动关联的流缓冲区。

参数

sb-streambuffer to use as output sequence
rhs-basic_ostream to initialize from

二次

#include <sstream> #include <utility> #include <iostream> int main() { // ERROR: copy ctor is deleted // std::ostream myout(std::cout // OK: shares buffer with cout std::ostream myout(std::cout.rdbuf() // ERROR: move constructor is protected // std::ostream s2(std::move(std::ostringstream() << 7.1) // OK: move ctor called through the derived class std::ostringstream s2(std::move(std::ostringstream() << 7.1) myout << s2.str() << '\n'; }

二次

产出:

二次

7.1

二次

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/io/basic[医]OFlow/BASIC[医]流