[concept.common] (original) (raw)

18 Concepts library [concepts]

18.4.6 Concept common_with [concept.common]

If T and U can both be explicitly converted to some third type,C, then T and U share a common type,C.

[Note 1:

C can be the same as T or U, or can be a different type.

C is not necessarily unique.

— _end note_]

template<class T, class U> concept [common_with](#concept:common%5Fwith "18.4.6 Concept common_­with [concept.common]") = [same_as](concept.same#concept:same%5Fas "18.4.2 Concept same_­as [concept.same]")<common_type_t<T, U>, common_type_t<U, T>> && requires { static_cast<common_type_t<T, U>>(declval<T>());static_cast<common_type_t<T, U>>(declval<U>());} && [common_reference_with](concept.commonref#concept:common%5Freference%5Fwith "18.4.5 Concept common_­reference_­with [concept.commonref]")< add_lvalue_reference_t<const T>, add_lvalue_reference_t<const U>> && [common_reference_with](concept.commonref#concept:common%5Freference%5Fwith "18.4.5 Concept common_­reference_­with [concept.commonref]")< add_lvalue_reference_t<common_type_t<T, U>>, common_reference_t< add_lvalue_reference_t<const T>, add_lvalue_reference_t<const U>>>;

Let C be common_type_t<T, U>.

Let t1 and t2 be equality-preserving expressions ([concepts.equality]) such thatdecltype((t1)) and decltype((t2)) are each T, and let u1 and u2 be equality-preserving expressions such thatdecltype((u1)) and decltype((u2)) are each U.

T and U model common_with<T, U>only if

[Note 2:

Users can customize the behavior of common_with by specializing thecommon_type class template ([meta.trans.other]).

— _end note_]