News for hackers. Stuff that matters.
Re:C++17 creates a practical use of the backward array index... by addaon on Monday April 03, 2023 @09:43PM (#35433892)
The key point of the article here is that this is no longer strict syntactic sugar in C++ as of C++17. The addition operator, like many operators and all function calls, does not specify the order that its arguments are evaluated. In C, and in C++ prior to C++14, neither did the indexing operator; but as of C++17, the order is fully defined (`a` first in `a[i]`).
Re:C++17 creates a practical use of the backward array index... by leni536 on Tuesday April 04, 2023 @01:52AM (#35435631)
Apart from sequencing rules, a[i] may also differ in value category. If one of the operands is an array rvalue then the result is also rvalue. *(a + i) can't propagate value category this way, dereferencing always produces an lvalue.