在线文档教程
C++
应用 | Utilities

std::swap(std::optional)

STD::交换%28 std::可选的%29

Defined in header
template< class T > void swap( optional<T>& lhs, optional<T>& rhs ) noexcept(/* see below */(since C++17)

重载std::swap算法std::optional.交换lhs与...rhs.有效地打电话lhs.swap(rhs)...

此函数模板不参与重载解析,除非std::is_move_constructible_v<T>和std::is_swappable_v<T>都是true...

参数

lhs, rhs-optional objects whose states to swap

返回值

%280%29

例外

noexcept规格:

noexcept(noexcept(lhs.swap(rhs)))

另见

swapexchanges the contents (public member function)

© cppreference.com

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

http://en.cppreference.com/w/cpp/实用程序/可选/swap 2