std::experi...nges::Common(3)
π std::experimental::ranges::Common π
okay so bestie, welcome to the C++ Standard Libary manual, specifically the page for std::experimental::ranges::Common in section 3. This is the Ranges TS corner of the library, and yes we're gonna read the whole concept together. β¨
π NAME π
std::experimental::ranges::Common β okay so this is literally just the concept named std::experimental::ranges::Common. That's the name, no cap. π«Ά
β¨ Synopsis β¨
Defined in header <experimental/ranges/concepts>:
template< class T, class U >
concept bool Common =
Same<ranges::common_type_t<T, U>, ranges::common_type_t<U, T>> &&
ConvertibleTo<T, ranges::common_type_t<T, U>> &&
ConvertibleTo<U, ranges::common_type_t<T, U>> &&
CommonReference<
std::add_lvalue_reference_t<const T>,
std::add_lvalue_reference_t<const U>> &&
CommonReference<
std::add_lvalue_reference_t<ranges::common_type_t<T, U>>,
ranges::common_reference_t<
std::add_lvalue_reference_t<const T>,
std::add_lvalue_reference_t<const U>>>;
The original synopsis also has the tag (ranges TS) hanging out in there, so yeah β this whole thing is Ranges TS business. π
The concept Common<T, U> specifies that two types T and U share a common type (as computed by ranges::common_type_t) to which both can be converted. That's the whole vibe: both types can slide into the same common type. π¦
Common<T, U> is satisfied only if, given expressions t and u such that decltype((t)) is T and decltype((u)) is U,
ranges::common_type_t<T, U>(t)is equal toranges::common_type_t<T, U>(t)if and only iftis an equality-preserving expression; andranges::common_type_t<T, U>(u)is equal toranges::common_type_t<T, U>(u)if and only ifuis an equality-preserving expression.
In other words (and this part is important, bestie), the conversion to the common type must not alter the equality-preservation property of the original expression. The conversion is not allowed to mess with that energy. π₯
πΈ Equality preservation πΈ
An expression is equality preserving if it results in equal outputs given equal inputs.
- The inputs to an expression consist of its operands.
- The outputs of an expression consist of its result and all operands modified by the expression (if any).
Every expression required to be equality preserving is further required to be stable: two evaluations of such an expression with the same input objects must have equal outputs absent any explicit intervening modification of those input objects. So like, same inputs, no touching anything in between, same outputs. Periodt. π―
π See also π
common_typeβ determine the common type of a set of types (class template)common_referenceβ determine the common reference type of a set of types (class template)CommonReferenceβ specifies that two types share a common reference type (concept)
bestie reminder: equality preservation and stability are not optional decorations, they're part of the requirements. Do not skip the vibe check. π
source/version/date sign-off: this page came from http://cppreference.com, version/date 2024.06.10, and it's the std::experi...nges::Common(3) manual page. mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms