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”.
[ Note: Function types (including those used in pointer to member function types) are never cv-qualified ([dcl.fct]). — end note ]
A conversion can add cv-qualifiers at levels other than the first in multi-level pointers, subject to the following rules:58
Two pointer types T1 and T2 are similar if there exists a type T and integer n > 0 such that:
T1is
cv1,0pointer to
cv1,1pointer to
⋯ cv1,n-1pointer to
cv1,n Tand
T2is
cv2,0pointer to
cv2,1pointer to
⋯ cv2,n-1pointer to
cv2,n Twhere each cvi,j is const, volatile, const volatile, or nothing. The n-tuple of cv-qualifiers after the first in a pointer type, e.g., cv1,1, cv1,2, ⋯, cv1,n in the pointer type T1, is called the cv-qualification signature of the pointer type. An expression of type T1 can be converted to type T2 if and only if the following conditions are satisfied:
the pointer types are similar.
for every j > 0, if const is in cv1,j then const is in cv2,j, and similarly for volatile.
if the cv1,j and cv2,j are different, then const is in every cv2,k for 0 < k < j.
[ 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; *pcc = &c; *pc = 'C'; }
— end note ]
A multi-level pointer to member type, or a multi-level mixed pointer and pointer to member type has the form:
cv0 P0to
cv1P1to
⋯ cvn-1Pn-1to
cvn Twhere Pi is either a pointer or pointer to member and where T is not a pointer type or pointer to member type.
Two multi-level pointer to member types or two multi-level mixed pointer and pointer to member types T1 and T2 are similar if there exists a type T and integer n > 0 such that:
T1is
cv1,0P0to
cv1,1P1to
⋯ cv1,n-1Pn-1to
cv1,n Tand
T2is
cv2,0P0to
cv2,1P1to
⋯ cv2,n-1Pn-1to
cv2,n TFor similar multi-level pointer to member types and similar multi-level mixed pointer and pointer to member types, the rules for adding cv-qualifiers are the same as those used for similar pointer types.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4