std::basic_stringbuf<CharT,Traits,Allocator>:: swap
|
void
swap
(
basic_stringbuf
&
rhs
)
;
|
(seit C++11)
(bis C++20) |
|
|
void
swap
(
basic_stringbuf
&
rhs
)
noexcept
(
/* siehe unten */
)
;
|
(seit C++20) | |
Tauscht den Zustand und die Inhalte von * this und rhs .
|
Das Verhalten ist undefiniert, wenn
|
(seit C++11) |
Inhaltsverzeichnis |
Parameter
| rhs | - |
another
basic_stringbuf
|
Rückgabewert
(keine)
Exceptions
|
Kann implementierungsdefinierte Ausnahmen werfen. |
(seit C++11)
(bis C++20) |
|
noexcept
Spezifikation:
noexcept
(
std::
allocator_traits
<
Allocator
>
::
propagate_on_container_swap
::
value
|| std:: allocator_traits < Allocator > :: is_always_equal :: value ) |
(seit C++20) |
Hinweise
Diese Funktion wird automatisch aufgerufen, wenn std::stringstream Objekte ausgetauscht werden. Es ist selten notwendig, sie direkt aufzurufen.
Beispiel
#include <iomanip> #include <iostream> #include <sstream> #include <string> int main() { std::istringstream one("one"); std::ostringstream two("two"); std::cout << "Before swap: one = " << std::quoted(one.str()) << ", two = " << std::quoted(two.str()) << ".\n"; one.rdbuf()->swap(*two.rdbuf()); std::cout << "After swap: one = " << std::quoted(one.str()) << ", two = " << std::quoted(two.str()) << ".\n"; }
Ausgabe:
Before swap: one = "one", two = "two". After swap: one = "two", two = "one".
Siehe auch
Konstruiert ein
basic_stringbuf
Objekt
(öffentliche Elementfunktion) |
|
|
(C++11)
|
tauscht zwei String-Streams
(öffentliche Elementfunktion von
std::basic_stringstream<CharT,Traits,Allocator>
)
|