std::basic_stringbuf<CharT,Traits,Allocator>::operator=
From cppreference.com
< cpp | io | basic stringbuf
| std::basic_stringbuf& operator=( std::basic_stringbuf&& rhs ); |
(1) | (C++11以降) |
| std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs ) = delete; |
(2) | |
1) 移動代入演算子: rhs の内容を *this に移動します。移動後、*this は rhs が以前保持していた関連文字列、オープンモード、ロケール、およびその他のすべての状態を保持します。*this の std::basic_streambuf の6つのポインタは、移動元 rhs の対応するポインタとは異なります(nullでない場合)。
目次 |
[編集] パラメータ
| rhs | - | 移動元となる別のbasic_stringbuf |
[編集] 戻り値
*this
[編集] 例
このコードを実行
#include <iostream> #include <sstream> #include <string> int main() { std::istringstream one("one"); std::ostringstream two("two"); std::cout << "Before move, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; *one.rdbuf() = std::move(*two.rdbuf()); std::cout << "After move, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; }
出力
Before move, one = "one" two = "two" After move, one = "two" two = ""
[編集] 関連項目
basic_stringbuf オブジェクトを構築する(public メンバ関数) |