名前空間
変種

std::basic_stringbuf<CharT,Traits,Allocator>::operator=

提供: cppreference.com
 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
<tbody> </tbody>
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 にムーブします。 ムーブの後、 *thisrhs がそれまで保持していた紐付けられた文字列、オープンモード、ロケール、およびその他のすべての状態を持ちます。 *this 内の std::basic_streambuf の6つのポインタはヌルでなければムーブされた rhs 内の対応するポインタと異なることが保証されます。
2) コピー代入演算子は削除されています。 basic_stringbufCopyAssignable ではありません。

引数

rhs - ムーブする別の basic_stringbuf

戻り値

*this

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

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 オブジェクトを構築します
(パブリックメンバ関数) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.