Is conversion and promotion the same thing?
There are two things that are called promotions: integral promotions and floating point promotions. Integral promotion refers to integral types (including bitfields and enum
s) being converted to "larger" integral types and floating point promotion is specifically just float
to double
.
Both types of promotions are subsets of a wider range of conversions.
char
->int
: integral promotionfloat
->double
: floating point promotionint
->char
: [narrowing] conversion (not a promotion)int
->float
: conversionconst char*
->std::string
: conversionFoo
->Bar
: possibly undefined conversion?- etc.
A promotion is a specific kind of conversion for built-in types that is guaranteed not to change the value.
The type you are promoting to must be able to accurately represent any possible value of the type you are promoting from.
Here is a list of the applicable conversions.