Can a string literal be subscripted in a constant expression?
问题 This is valid, because a constexpr expression is allowed to take the value of "a glvalue of literal type that refers to a non-volatile object defined with constexpr, or that refers to a sub-object of such an object" (§5.19/2): constexpr char str[] = "hello, world"; constexpr char e = str[1]; However, it would seem that string literals do not fit this description: constexpr char e = "hello, world"[1]; // error: literal is not constexpr 2.14.5/8 describes the type of string literals: Ordinary