MoonBun
MoonBun

Reputation: 4402

dereference of a reference

When writing this:

void foo(int*& x);

instead of & neutralizing the *, foo accepts x reference of a type int*, if I understand correctly.

but what happens when I write this:

void foo(int&* x);

is that a pointer to a reference? will the compiler optimize it and take the actual value? since dereferencing a reference if the value it self.

EDIT:

so I can't take pointer to reference, but why is that? does it have to do with the address of the reference being a stack address?

Upvotes: 0

Views: 373

Answers (2)

T.C.
T.C.

Reputation: 137310

§8.3.2 [dcl.ref]/p5:

There shall be no references to references, no arrays of references, and no pointers to references.

Upvotes: 3

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136208

int&* is not well-formed, no pointer to a reference can be taken.

Upvotes: 2

Related Questions