C++11 std::size() Equivalent Function

c++c++11

Given a builtin array x of arbitrary type T, there are functions std::begin() and std::end() that I can call, but why isn't there a std::size()? Seems odd not to have that.

I could use std::end(x)-std::begin(x), but still a std::size(x) would be better.

Yes, I know of the std::vector and std::array classes. This is just a question of why something as simple as this isn't available as yet in the STL.

Best Answer

Just a note to let people know that N4280 "Non-member size() and more (Revision 2)" has been accepted into the C++17 Working Draft. This includes std::size() as well as std::empty() and std::data().

Related Question