◐ Shell
clean mode source ↗

std::basic_ostream::basic_ostream – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

explicit basic_ostream( std::basic_streambuf<CharT, Traits>* sb );

(1)

protected: basic_ostream( const basic_ostream& rhs ) = delete;

(2)

protected: basic_ostream( basic_ostream&& rhs );

(3) (seit C++11)

1)

Konstruiert den basic_ostream Objekt zuweisen Startwerte der Basisklasse durch Aufruf basic_ios::init(sb) .

Original:

Constructs the basic_ostream object, assigning initial values to the base class by calling basic_ios::init(sb).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Der Copy-Konstruktor ist geschützt, und wird gelöscht. Output-Streams sind nicht kopierbar .

Original:

The copy constructor is protected, and is deleted. Output streams are not copyable.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3)

Der Umzug Konstruktor verwendet basic_ios<CharT, Traits>::move(rhs) alle basic_ios Mitglieder zu bewegen, mit Ausnahme der rdbuf() von rhs in *this. Dieser Schritt Konstruktor geschützt ist: es wird durch die Bewegung Konstruktoren von beweglichen Ausgabe-Stream-Klassen aufgerufen std::basic_ofstream und std::basic_ostringstream, die wissen, wie man richtig zu bewegen das zugehörige streambuffer .

Original:

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.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parameter

sb -

streambuffer als Ausgang Sequenz zu verwenden

Original:

streambuffer to use as output sequence

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

rhs -

basic_ostream aus initialisieren

Original:

basic_ostream to initialize from

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Beispiel

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

Output: