在线文档教程
C++
字符串 | Strings

std::swap(std::basic_string)

STD::交换%28 std::basic[医]字符串%29

template< class CharT, class Traits, class Alloc > void swap( std::basic_string &lhs, std::basic_string &rhs (until C++17)
template< class CharT, class Traits, class Alloc > void swap( std::basic_string<CharT, Traits, Alloc> &lhs, std::basic_string<CharT, Traits, Alloc> &rhs ) noexcept(/* see below */(since C++17)

专攻std::swap算法std::basic_string.交换lhsrhs相当于lhs.swap(rhs)...

参数

lhs, rhs-strings whose contents to swap

返回值

%280%29

复杂性

常量。

Exceptions noexcept specification: noexcept(noexcept(lhs.swap(rhs)))(since C++17)

另见

swapswaps the contents (public member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/basic[医]字符串/SWAP 2