- syncstream[meta header]
- function[meta id-type]
- std[meta namespace]
- basic_syncbuf[meta class]
- cpp20[meta cpp]
void swap(basic_syncbuf& other) noexcept;
他のbasic_syncbuf
オブジェクトと、データを交換する。
allocator_traits<Allocator>::propagate_on_container_swap::value
がtrue
であるか、または
this->get_allocator() == other.get_allocator()
がtrue
である。
*this
とother
の状態を交換する。
なし
投げない
#include <iostream>
#include <syncstream>
int main()
{
std::osyncstream aout{std::cout};
aout << "Hello, ";
std::osyncstream bout;
bout << "World!";
aout.rdbuf()->swap(*bout.rdbuf());
bout.emit(); // "Hello, " が転送される
aout.emit(); // "World!" が転送される
}
- swap[color ff0000]
Hello, World!
- C++20
- Clang: ??
- GCC: 11.1 [mark verified]
- Visual C++: 2019 update 10 [mark verified]