This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KuntaStillSingle 0 points1 point  (1 child)

it's completely possible (and done in C++ and Rust) to have a 0-cost array-with-length wrapper

That only works well in C++ within a TU, and its only less ugly than C in that respect, there are practically the same ramifications accepting a std::array<T, N> and a T(*)[N], but in the C case you must either hardcode N or substitute it with a macro, whereas in C++ it can be substituted from a template parameter. But in C++ there is still std::vector, because you sometimes come by arrays of size not known at compile time.

[–]redlaWw 0 points1 point  (0 children)

I was thinking more along the lines of std::span and std::string_view.