I'm reading a book called C++ Gotchas which explains the conversions between const pointers and I'm having some trouble understanding the following rules:
Two pointer types T1 and T2 are similar if there exists a type T and integer n > 0 such that:
T1 is cv 1 , 0 pointer to cv 1,1 pointer to . . . cv 1,n−1 pointer to cv 1,n T
and,
T2 is cv 2,0 pointer to cv 2,1 pointer to . . . cv 2,n−1 pointer to cv 2,n T
where each cvi,j is const, volatile, const volatile, or nothing.
Can someone point me to right direction where I can get an explanation or is anyone familiar with what cv 1,0 and cv 1,1 means in each of above sequence ? The book isn't helping me enough to understand it. But I'm sure this has got something to do with C++ language.
cv i,jrepresents a collection of 2*(n+1) placeholders:For every combination of
iwith1 <= i <= 2andjwith0 <= j <= nthe placeholdercv i,jstands for one of the three specifiersconst,volatile, const volatlieor nothing.The book excerpt in other words means, that if these placeholders and a type
Tcan be found such that the two statements ("T1 is ..") are satisfied, thenT1andT2are called "similar".For example
T1 = const int*andT2 = int*are similar, because they fullfill the two statements from the excerpt, if one chooses:T = int,n = 1cv1,0= {nothing}andcv1,1 = constcv2,0={nothing}andcv2,1 = {nothing}To see this, just insert the placeholders:
const int*is pointer toconst intint*is pointer toint