std::swappable, std::swappable_with

Header: <concepts>

The concept swappable specifies that lvalues of type T are swappable.

# Declarations

template< class T >
concept swappable =
requires(T& a, T& b) {
ranges::swap(a, b);
};

(since C++20)

template< class T, class U >
concept swappable_with =
std::common_reference_with<T, U> &&
requires(T&& t, U&& u) {
ranges::swap(std::forward<T>(t), std::forward<T>(t));
ranges::swap(std::forward<U>(u), std::forward<U>(u));
ranges::swap(std::forward<T>(t), std::forward<U>(u));
ranges::swap(std::forward<U>(u), std::forward<T>(t));
};

(since C++20)