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 enums) 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 promotion
  • float -> double: floating point promotion
  • int -> char: [narrowing] conversion (not a promotion)
  • int -> float: conversion
  • const char* -> std::string: conversion
  • Foo -> 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.

Tags:

C++

Types

Casting