名稱空間
變體
操作

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

來自 cppreference.com
< cpp‎ | io‎ | basic_stringbuf
 
 
 
 
(1) (C++11 起)
std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs ) = delete;
(2)
1) 移動賦值運算子:將 rhs 的內容移動到 *this。移動後,*this 擁有先前由 rhs 持有的相關字串、開啟模式、區域設定和所有其他狀態。*thisstd::basic_streambuf 的六個指標保證與從 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) [編輯]