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.
std::size
only work for a type if it is cheap, or should it work regardless?std::begin()
andstd::end()
?std::valarray::begin
. The only container for which you can't add such a member isT[]
.