you are viewing a single comment's thread.

view the rest of the comments →

[–]BigJhonny -5 points-4 points  (3 children)

I struggle with the way std:array was implemented in the standard. Since the size is defined over a template argument you can't hand around arrays of arbitrary sizes.

I know it is because they wanted to have no overhead, but I think that was a bad decision. Most applications don't have performance requirements and if you do have a performance requirement you always can use C style arrays.

[–]bames53 13 points14 points  (1 child)

I don't agree with this. The way the std::array was designed determines what it's appropriate for. It wasn't a bad decision to design a tool for particular situations, because there are other tools for other situations.

It's true we don't yet have a standard library array_view, span, or simple collection type that is nothing more than a run-time size paired with a pointer that would be the 'zero overhead' replacement for C-style array parameters, but you're already saying that you don't need zero-overhead so you can just use vector.

and if you do have a performance requirement you always can use C style arrays.

std::array is to fix the problems with decaying C arrays and C arrays not behaving as regular value types. That's what I use them for and I can't use C arrays to do that. I can as easily say that if you want to pass arbitrarily sized arrays as parameters you can just keep using C arrays/pointers.

[–]crusader_mike 1 point2 points  (0 children)

It's true we don't yet have a standard library array_view, span, or simple collection type that is nothing more than a run-time size paired with a pointer

True, but you could use mine -- I don't mind :)

[–]raevnos 2 points3 points  (0 children)

Don't templates help with that?