名前空間
変種
操作

std::basic_istream<CharT,Traits>::operator=

From cppreference.com
< cpp‎ | io‎ | basic istream
 
 
 
 
protected:
basic_istream& operator=( const basic_istream& rhs ) = delete;
(1)
protected:
basic_istream& operator=( basic_istream&& rhs );
(2) (C++11以降)
1) コピー代入演算子は保護されており、削除されています。入力ストリームはCopyAssignableではありません。
2) ムーブ代入演算子は、gcount()の値と、rdbuf()を除く基底クラスのすべてのデータメンバーを、rhsと交換します。これは、swap(*rhs)を呼び出すようなものです。このムーブ代入演算子は保護されています。これは、派生したムーブ可能な入力ストリームクラスであるstd::basic_ifstreamおよびstd::basic_istringstreamのムーブ代入演算子によってのみ呼び出されます。これらのクラスは、関連するストリームバッファを正しくムーブ代入する方法を知っています。

[編集] パラメータ

rhs - *thisに代入するbasic_istreamオブジェクト

[編集]

#include <iostream>
#include <sstream>
 
int main()
{
    std::istringstream s1;
    s1 = std::istringstream("test"); // OK
 
//  std::cin = std::istringstream("test"); // ERROR: 'operator=' is protected
}
English 日本語 中文(简体) 中文(繁體)