std::basic_stringbuf<CharT,Traits,Allocator>:operator=
Von cppreference.com
< cpp | io | basic stringbuf
| std::basic_stringbuf& operator=( std::basic_stringbuf&& rhs ); |
(1) | (seit C++11) |
| std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs ) = delete; |
(2) | |
1) Move-Zuweisungsoperator: Verschiebt den Inhalt von rhs nach *this. Nach der Verschiebung hat *this den zugehörigen String, den Öffnungsmodus, das Locale und alle anderen Zustände, die rhs zuvor innehatte. Die sechs Zeiger von std::basic_streambuf in *this sind garantiert anders als die entsprechenden Zeiger im verschobenen rhs, es sei denn, sie sind null.
Inhalt |
[bearbeiten] Parameter
| rhs | - | ein weiterer basic_stringbuf, von dem verschoben wird |
[bearbeiten] Rückgabewert
*this
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#include <iostream> #include <sstream> #include <string> int main() { std::istringstream one("one"); std::ostringstream two("two"); std::cout << "Before move, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; *one.rdbuf() = std::move(*two.rdbuf()); std::cout << "After move, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; }
Ausgabe
Before move, one = "one" two = "two" After move, one = "two" two = ""
[bearbeiten] Siehe auch
konstruiert ein basic_stringbuf-Objekt(public member function) |