Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/concepts/common reference with"

From cppreference.com
< cpp‎ | concepts
(move page (P1754R1))
 
(Added Spanish language link)
Line 25: Line 25:
 
{{dsc end}}
 
{{dsc end}}
  
{{langlinks|ja|zh}}
+
{{langlinks|es|ja|zh}}

Revision as of 20:50, 12 February 2020

Defined in header <concepts>
template < class T, class U >

concept common_reference_with =
  std::same_as<std::common_reference_t<T, U>, std::common_reference_t<U, T>> &&
  std::convertible_to<T, std::common_reference_t<T, U>> &&

  std::convertible_to<U, std::common_reference_t<T, U>>;
(since C++20)

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

T and U model common_reference_with<T, U> only if, given equality-preserving expressions t1, t2, u1 and u2 such that decltype((t1)) and decltype((t2)) are both T and decltype((u1)) and decltype((u2)) are both U,

In other words, the conversion to the common reference type must preserve equality.

Equality preservation

Expressions declared in requires expressions of the standard library concepts are required to be equality-preserving (except where stated otherwise).

See also

determines the common reference type of a group of types
(class template) [edit]
specifies that two types share a common type
(concept) [edit]
determines the common type of a group of types
(class template) [edit]