Namespaces
Variants

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

From cppreference.net
(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でない限り異なることが保証される。
2) コピー代入演算子は削除されています; basic_stringbuf CopyAssignable ではありません。

目次

パラメータ

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)