std::common_with

Header: <concepts>

The concept common_with<T, U> specifies that two types T and U share a common type (as computed by std::common_type_t) to which both can be converted.

# Declarations

template< class T, class U >
concept common_with =
std::same_as<std::common_type_t<T, U>, std::common_type_t<U, T>> &&
requires {
static_cast<std::common_type_t<T, U>>(std::declval<T>());
static_cast<std::common_type_t<T, U>>(std::declval<U>());
} &&
std::common_reference_with<
std::add_lvalue_reference_t<const T>,
std::add_lvalue_reference_t<const U>> &&
std::common_reference_with<
std::add_lvalue_reference_t<std::common_type_t<T, U>>,
std::common_reference_t<
std::add_lvalue_reference_t<const T>,
std::add_lvalue_reference_t<const U>>>;

(since C++20)

# See also