Is the “one-past-the-end” pointer of a non-array type a valid concept in C++?

后端 未结 1 1207
不思量自难忘°
不思量自难忘° 2020-11-29 09:56

The C++ standard [sec 5.7] says:

If both the pointer operand and the result point to elements of the same array object, or one past the last element

相关标签:
1条回答
  • 2020-11-29 10:52

    No, it is legal. 5.7(4) - one paragraph before your quote - says: "For the purposes of these operators, a pointer to a nonarray object behaves the same as a pointer to the first element of an array of length one with the type of the object as its element type."

    0 讨论(0)
提交回复
热议问题