C++ 参考手册

位置:首页 > C++ 参考手册 >容器库 >std::forward_list > std::swap(std::forward_list)

template< class T, class Alloc >

void swap( forward_list<T,Alloc>& lhs,

           forward_list<T,Alloc>& rhs );
(C++11 èµ·)
(C++17 前)
template< class T, class Alloc >

void swap( forward_list<T,Alloc>& lhs,

           forward_list<T,Alloc>& rhs ) noexcept(/* see below */);
(C++17 èµ·)

为 std::forward_list 特化 std::swap 算法。交换 lhs 与 rhs 的内容。调用 lhs.swap(rhs) 。

参数

lhs, rhs - 要交换内容的容器

返回值

(无)

复杂度

常数。

异常

noexcept 规定:  
noexcept(noexcept(lhs.swap(rhs)))
(C++17 èµ·)

参阅

交换内容
(公开成员函数)