std::basic_stringbuf<CharT,Traits,Allocator>::operator=
来自 cppreference.com
< cpp | io | basic stringbuf
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 中。移动后,*this 将拥有与之关联的字符串、打开模式、区域设置以及以前由 rhs 持有的所有其他状态。保证 *this 中的 std::basic_streambuf 的六个指针与移动前 rhs 中的对应指针不同,除非为 null。
内容 |
[编辑] 参数
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 对象(公有成员函数) |