std::swap(std::variant)

std::swap(std::variant)

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

Overloads the std::swap algorithm for std::variant. Effectively calls lhs.swap(rhs).

This overload only participates in overload resolution if is_move_constructible_v<T_i> and is_swappable_v<T_i> are both true for all T_i in Types...

Parameters

lhs, rhs - variant objects whose values to swap

Return value

(none).

Exceptions

noexcept specification:
noexcept(noexcept(lhs.swap(rhs)))

Example

See also

swaps with another variant
(public member function)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/variant/swap2

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部