Before the array decays to a pointer, you can get its length.
Here is the implementation of std::begin for arrays in libc++: https://github.com/llvm-mirror/libcxx/blob/60d223df071f6e3d4...
Quite right, I'm apparently rusty on my stdlib knowledge. Didn't know about the reference trick.
Re:Ill-Advised C++ Rant, Part 2
by onedognight on Sunday March 06, 2016 @10:08PM
(#11236871)
Yes you can call std::begin() and std::end() on an array.
int a[] = {4,5,6};
for(int i : a)
;
That is how the above works.
Start ignoring here: Are you suggesting end() and begin() can be called on an array? As far as I know they can't. Apparently you can deduce array length in a constexpr function now in C++11 (which I only learned just now but also couldn't get working quickly, so have some salt with that), but before that arrays always degrade to pointers when passed as function arguments so there's (afaik) no way to extract their length from their type...