std::common_type

Header: <type_traits>

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.

# Declarations

template< class... T >
struct common_type;

(since C++11)

# 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().

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2141C++11the result type of the conditional operator was not decayeddecayed the result type
LWG 2408C++11common_type was not SFINAE-friendlymade SFINAE-friendly
LWG 2460C++11common_type specializations were nearly impossible to writereduced the number ofspecializations needed

# See also