0

In Modern C++, we can use std::end on native arrays. I wanted to ask how does this work to understand the performance considerations for this.

Jubin Chheda
  • 534
  • 4
  • 11

1 Answers1

1

If you have an array called a with size N, then std::end(a) means the same thing as a + N. It doesn't need to do any run-time work to find the size of the array, because the size is known at compile time.

Note that std::end won't work on a pointer. It will only work on an array that has not been decayed to a pointer, so the size information is statically present at the call site.

Brian Bi
  • 111,498
  • 10
  • 176
  • 312