Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 1.26 KB

File metadata and controls

72 lines (49 loc) · 1.26 KB

swap

  • 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::valuetrueであるか、または this->get_allocator() == other.get_allocator()trueである。

効果

*thisotherの状態を交換する。

戻り値

なし

例外

投げない

#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

処理系

参照