Legal Conversions

You can do explicit conversions from a given type to another type if the conversion can be done using standard conversions. The results are the same. The conversions described in this section are legal; any other conversions not explicitly defined by the user (for a class type) are illegal.

A value of integral type can be explicitly converted to a pointer if the pointer is large enough to hold the integral value. A pointer that is converted to an integral value can be converted back to a pointer; its value is the same. This identity is given by the following (where p represents a pointer of any type):

p == (type *) integral-conversion( p )

With explicit conversions, the compiler does not check whether the converted value fits in the new type except when converting from pointer to integral type or vice versa.

This section describes the following conversions:

Community Additions