std::experimental::ranges::common_type - cppreference.com (original) (raw)

Determines the common type among all types T..., that is the type all T... can be implicitly converted to. If such a type exists (as determined according to the rules below), the member type names that type. Otherwise, there is no member type. The behavior is undefined if any of the types in T... is an incomplete type other than (possibly cv-qualified) void.

[edit] Member types

Name Definition
type the common type for all T...

[edit] Helper types

| template< class... T > using common_type_t = typename common_type<T...>::type; | | | | ------------------------------------------------------------------------------------ | | |

[edit] Specializations

Users may specialize common_type for types T1 and T2 if

If such a specialization has a member named type, it must be a public and unambiguous member type that names a cv-unqualified non-reference type to which both T1 and T2 are explicitly convertible. Additionally, ranges::common_type_t<T1, T2> and ranges::common_type_t<T2, T1> must denote the same type.

A program that adds common_type specializations in violation of these rules has undefined behavior.

[edit] Notes

For arithmetic types not subject to promotion, the common type may be viewed as the type of the (possibly mixed-mode) arithmetic expression such as T0() + T1() + ... + Tn().

[edit] Example

[edit] See also