std::basic_stringbuf<CharT,Traits,Allocator>::swap
提供: cppreference.com
< cpp | io | basic stringbuf
void swap( std::basic_stringbuf& rhs ) |
(C++11以上) | |
*this と rhs
の状態および内容を入れ替えます。
目次 |
[編集] 引数
rhs | - | 別の basic_stringbuf
|
[編集] 戻り値
(なし)
[編集] ノート
この関数は std::stringstream オブジェクトを swap するときに自動的に呼ばれます。 直接呼ぶ必要はほとんどありません。
[編集] 例
Run this code
#include <sstream> #include <string> #include <iostream> int main() { std::istringstream one("one"); std::ostringstream two("two"); std::cout << "Before swap, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; *one.rdbuf()->swap(*two.rdbuf()); std::cout << "Before swap, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; }
出力:
Before swap, one = "one" two = "two" Before swap, one = "two" two = "one"
[編集] 関連項目
basic_stringbuf オブジェクトを構築します (パブリックメンバ関数) | |
(C++11) |
2つの文字列ストリームを入れ替えます ( std::basic_stringstream<CharT,Traits,Allocator> のパブリックメンバ関数)
|