A patch was posted to gcc that provides something called vector subscripting to g++ (gcc already had it).
If a
is an array and i
is an int then i[a]
is legal and equal to a[i]
.
double a[]{0.0, 1.0, 2.0, 3.0}; // C++11 style but would work in C++98 style too.
assert(a[2] == 2.0);
assert(2[a] == 2.0);
So, is this legal and standard C/C++ or is it a gcc extension?
Actually, Google shows MS Developer Studio has this too. I looked in the C++ standard and didn't see it though.