std::basic_stringbuf<CharT,Traits,Allocator>:: operator=
From cppreference.net
<
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
が以前保持していた関連付けられた文字列、オープンモード、ロケール、およびその他の全ての状態を持つ。
std::basic_streambuf
の6つのポインタは、
*
this
内において、ムーブ元の
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 member function) |