std::basic_ostream<CharT,Traits>::basic_ostream
From cppreference.com
 
 
 < cpp | io | basic ostream 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Input/output library 
 
 
 
 
 
 
 
 
 
 
 
 
 Print functions (C++23)
 Buffers
(C++23)
(C++98/26*)
(C++20)
 Streams
 Abstractions
 File I/O
 String I/O
 Array I/O
(C++23)
(C++23)
(C++23)
(C++98/26*)
(C++98/26*)
(C++98/26*)
 Synchronized Output
(C++20)
 Types
 Error category interface
(C++11)
(C++11)
std::basic_ostream 
 
 
 
 
 
 
 
 Global objects
 Member functions
basic_ostream::basic_ostream
(C++11)
 Formatted output
 Unformatted output
 Positioning
 Miscellaneous
(C++11)
 Member classes
 Non-member functions
(C++23)
(C++23)
(C++23)
(C++23)
explicit basic_ostream( std::basic_streambuf <CharT, Traits>* sb );
 (1) 
 
protected:
basic_ostream( const basic_ostream& rhs ) = delete;
 (2) 
 (since C++11) 
basic_ostream( const basic_ostream& rhs ) = delete;
protected:
basic_ostream( basic_ostream&& rhs );
 (3) 
 (since C++11) 
basic_ostream( basic_ostream&& rhs );
1) Constructs the 
basic_ostream object, assigning initial values to the base class by calling basic_ios::init(sb) .2) The copy constructor is protected, and is deleted. Output streams are not copyable.
3) The move constructor 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 output stream classes std::basic_ofstream  and std::basic_ostringstream , which know how to correctly move the associated streambuffer.[edit] Parameters
 sb
 -
 streambuffer to use as output sequence
 rhs
 -
 basic_ostream to initialize from
[edit] Notes
Because basic_ios::init(sb)  sets badbit when sb is a null pointer, and because basic_ostream::sentry does nothing if the stream is already in a failed state, writing to a stream constructed from a null pointer sb is a no-op.
[edit] Example
Run this code
#include <iostream> #include <sstream> #include <utility> 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::ostringstream () << 7.1); myout << s2.str() << '\n'; std::ostream dev_null{nullptr}; // see Notes above dev_null << "no-op"; }
Output:
7.1