最終更新日時(UTC):
が更新

履歴 編集

function
<syncstream>

std::basic_syncbuf::swap (非メンバ関数)(C++20)

namespace std {
template<class charT, class traits, class Allocator>
  void swap(basic_syncbuf<charT, traits, Allocator>& a,
            basic_syncbuf<charT, traits, Allocator>& b) noexcept;
}

概要

2つのbasic_syncbufオブジェクトを入れ替える。

効果

a.swap(b);と等価である。

戻り値

なし

例外

投げない

#include <iostream>
#include <syncstream>

int main()
{
  std::osyncstream aout{std::cout};
  aout << "Hello, ";

  std::osyncstream bout;
  bout << "World!";

  std::swap(*aout.rdbuf(), *bout.rdbuf());

  bout.emit(); // "Hello, " が転送される
  aout.emit(); // "World!" が転送される
}

出力

Hello, World!

バージョン

言語

  • C++20

処理系

参照