std::swap(std::variant) - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::swap(std::variant)

From cppreference.com
< cpp‎ | utility‎ | 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...`

### [edit] Parameters

lhs, rhs | - | `variant` objects whose values to swap

### [edit] Return value

(none)

### [edit] Exceptions

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

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

swap | swaps with another variant (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/variant/swap2&oldid=92116"
Categories:

- conditionally noexcept
- Todo no example