std::basic_stringbuf::swap
来自cppreference.com
< cpp | io | basic stringbuf
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
void swap( std::basic_stringbuf& rhs ) |
(C++11 起) | |
交换的状态和内容*this和
rhs
.原文:
Swaps the state and the contents of *this and
rhs
.目录 |
[编辑] 参数
rhs | - | 另一个
basic_stringbuf |
[编辑] 返回值
(无)
[编辑] 注释
此功能称为自动交换std::stringstream对象时,很少需要直接调用它.
原文:
This function is called automatically when swapping std::stringstream objects, it is rarely necessary to call it directly.
[编辑] 示例
#include <sstream> #include <string> #include <iostream> int main() { std::istringstream one("one"); std::ostringstream two("two"); std::cout << "Before swap, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; *one.rdbuf()->swap(*two.rdbuf()); std::cout << "Before swap, one = \"" << one.str() << '"' << " two = \"" << two.str() << "\"\n"; }
输出:
Before swap, one = "one" two = "two" Before swap, one = "two" two = "one"
[编辑] 另请参阅
构造一个的basic_stringbuf对象 (公共成员函数) | |
(C++11) |
swaps two string streams (公共成员函数of std::basic_stringstream )
|