std::basic_stringbuf::swap
性病:基本[医]字符串::交换
void swap( std::basic_stringbuf& rhs ) | | (since C++11) |
---|
交换状态和内容*this
和rhs
...
参数
rhs | - | another basic_stringbuf |
---|
返回值
%280%29
注记
此函数在交换时自动调用。std::stringstream
对象时,很少有必要直接调用它。
例
二次
#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"
二次
另见
(constructor) | constructs a basic_stringbuf object (public member function) |
---|---|
swap (C++11) | swaps two string streams (public member function of std::basic_stringstream) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。