According to the C++23 standard, what is the output of this program?
#include <iostream>
int main() {
std::cout << 1["ABC"];
}The expression E1[E2] is identical to *((E1)+(E2)).
B
§[expr.sub]¶2 in the standard:
The expression
E1[E2]is identical (by definition) to*((E1)+(E2))(...).
In our case 1["ABC"] is identical to *(1+"ABC"). Since the plus operator is commutative, this is identical to *("ABC"+1), which is identical to the more familiar "ABC"[1].