std::basic_stringbuf<CharT,Traits,Allocator>::operator=
来自 cppreference.cn
< 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 对象(public member function) |