Could you explain the magic behind (1+3)[a]
indexing as in the following code? (taken from here)
#include <iostream>
int main(int argc, const char * argv[]) {
int a[] = {1, 2, 3, 4, 5, 6};
std::cout << (1 + 3)[a] - a[0] + (a + 1)[2];
}
Is this indexing some relic of C language? I thought indexing operator []
cannot take an array in it. Would the same work for e.g. std::vector
?