Links to links are illegal in C ++ 03, but you do not create them.
The following code tries to create a link to a link:
int main(){ int c = 0; typedef int & IREF; int & c1 = c; IREF & c2 = c1; int & & c3 = c1; }
... and fails when g ++ is put into C ++ 03 mode:
> g++-4.9 -std=c++03 -O2 -Wall -pedantic -pthread main.cpp main.cpp: In function 'int main()': main.cpp:5:12: error: cannot declare reference to 'IREF {aka int&}' IREF & c2 = c1; ^ main.cpp:6:13: error: cannot declare reference to 'int&', which is not a typedef or a template type argument int & & c3 = c1; ^
As noted in another answer, C ++ 11 added new link folding rules to make IREF & c2 = c1; correct, but not int & & c3 = c1; , int & is neither a typedef name nor a decltype specifier.
source share