命名空间
变体
操作

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

来自 cppreference.cn
< cpp‎ | io‎ | basic stringbuf
 
 
 
 
(1) (since C++11)
std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs ) = delete;
(2)
1) 移动赋值运算符:将 rhs 的内容移动到 *this。移动后,*this 拥有与 rhs 之前持有的关联字符串、打开模式、区域设置和所有其他状态。 std::basic_streambuf*this 的六个指针保证与移动前的 rhs 中的对应指针不同,除非为空。
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 对象
(公共成员函数) [编辑]