swap(std::expected)

< cpp‎ | utility‎ | expected
friend constexpr void swap( expected& lhs, expected& rhs ) noexcept(/*见下文*/);
(C++23 起)

std::expected 重载的 std::swap 算法。交换 lhsrhs 的状态。等价于 lhs.swap(rhs)

此重载只有在 lhs.swap(rhs) 合法时才会参与重载决议。

此函数对通常无限定有限定查找不可见,而只能在 std::expected<T, E> 为参数的关联类时由实参依赖查找找到。

参数

lhs, rhs - 要交换状态的 expected 对象

返回值

(无)

异常

noexcept 说明:  
noexcept(noexcept(lhs.swap(rhs)))

示例

参阅

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