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

履歴 編集

function template
<sstream>

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

namespace std {
  template<class CharT, class Traits, class Allocator>
  void swap(basic_stringbuf<CharT, Traits, Allocator>& x,
            basic_stringbuf<CharT, Traits, Allocator>& y);
}

概要

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

効果

x.swap(y)

#include <iostream>
#include <sstream>
#include <string>

int main()
{
  std::stringbuf buf1("first");
  std::stringbuf buf2("second");

  std::swap(buf1, buf2);

  std::cout << buf1.str() << std::endl;
  std::cout << buf2.str() << std::endl;
}

出力

second
first

バージョン

言語

  • C++11

処理系