T * and const T *

I believe that this can apply to many Ts, but I know for sure that this applies to integers. As part of C ++ training, I am trying to explain the following behavior in terms of the language in the standard.

typedef const int * constintptr;
typedef int * intptr;

intptr p;
constintptr cp = p;
const constintptr& crcp = p;
//constintptr & rcp = p;

From a look at n3337, paragraph 8.5.3. This behavior seems to be explained by the fact that int * is converted to const int * prvalue, but is not referenced. (correct me if I am wrong).

I see that this is the desired behavior (or we can undermine const), and the desirability of such behavior is not the issue in question.

The question is where the standard states (or implies) that they intptr and constintptr are not referenced.

+4
source share
1 answer

, 8.5.3/4 ( n3797, ) :

"cv1 T1" "cv2 T2" , "cv1 T1" "cv2 T2" , T1 - , T2, T1 T2. "cv1 T1" "cv2 T2" , T1, T2 cv1, cv-, cv-, cv2

, T1 int* T2 int const*. . ( ). .

"cv1 T1", , 0 const, volatile T1. , .. - , 0 const, volatile, , T1.

, , , , , const int* int* cv. , , . . int *const - cv- int*.

+7

All Articles