std::swap(std::basic_string)
来自cppreference.com
                    
                                        
                    < cpp | string | basic string
                    
                                                            
                    |   在标头  <string> 定义
  | 
||
|   template< class CharT, class Traits, class Alloc > void swap( std::basic_string<CharT, Traits, Alloc> &lhs,  | 
(C++17 前) | |
|   template< class CharT, class Traits, class Alloc > void swap( std::basic_string<CharT, Traits, Alloc> &lhs,  | 
 (C++17 起)  (C++20 前)  | 
|
|   template< class CharT, class Traits, class Alloc > constexpr void  | 
(C++20 起) | |
对 std::basic_string 特化 std::swap 算法。交换 lhs 与 rhs 的内容。等价于 lhs.swap(rhs) 。
参数
| lhs, rhs | - | 要交换内容的 string | 
返回值
(无)
复杂度
常数。
异常noexcept 说明:  
 
noexcept(noexcept(lhs.swap(rhs)))  | 
(C++17 起) | 
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 | 
|---|---|---|---|
| LWG 2064 | C++11 |  非成员 swap 为 noexcept 并与成员 swap 不一致
 | 
移除 noexcept | 
参阅
|   交换内容  (公开成员函数)  |