A cv-decomposition of a type T is a sequence of and such that T is “ ⋯ U” for , where each is a set of cv-qualifiers, and each is “pointer to”, “pointer to member of class of type”, “array of ”, or “array of unknown bound of”. If designates an array, the cv-qualifiers on the element type are also taken as the cv-qualifiers of the array. [ Example: The type denoted by the type-id const int ** has two cv-decompositions, taking U as “int” and as “pointer to const int”. — end example ] The n-tuple of cv-qualifiers after the first one in the longest cv-decomposition of T, that is, , is called the cv-qualification signature of T.
Two types and are similar if they have cv-decompositions with the same n such that corresponding components are the same and the types denoted by U are the same.
A prvalue expression of type can be converted to type if the following conditions are satisfied, where denotes the cv-qualifiers in the cv-qualification signature of :60
and are similar.
For every , if const is in then const is in , and similarly for volatile.
If the and are different, then const is in every for .
[ Note: If a program could assign a pointer of type T** to a pointer of type const T** (that is, if line #1 below were allowed), a program could inadvertently modify a const object (as it is done on line #2). For example,
int main() {
const char c = 'c';
char* pc;
const char** pcc = &pc; // #1: not allowed
*pcc = &c;
*pc = 'C'; // #2: modifies a const object
}— end note ]
[ Note: A prvalue of type “pointer to cv1 T” can be converted to a prvalue of type “pointer to cv2 T” if “cv2 T” is more cv-qualified than “cv1 T”. A prvalue of type “pointer to member of X of type cv1 T” can be converted to a prvalue of type “pointer to member of X of type cv2 T” if “cv2 T” is more cv-qualified than “cv1 T”. — end note ]
[ Note: Function types (including those used in pointer to member function types) are never cv-qualified ([dcl.fct]). — end note ]
These rules ensure that const-safety is preserved by the conversion.