mardi 16 février 2021

Why did STL made a(nother) distinction between a std::array and a std::initializer_list

Why is there not only 1 type with the best performance, to define a list at compile time?

The benchmark is clear, the constexpr std::initializer_list is faster, uses even less memory and the IO-reads are astonishingly less over constexpr std::array:

https://build-bench.com/b/1EDAcFjJ6NACk4Pg4tG2nbsEx0A

Why do people praise std::array even if you have to add the number of elements (how stupid is that, when adding another element, you need to change 2 lines, and why can't std::array not deduce the length automatically?).

So why didn't they implement the array subscription methods to std::initializer_list make std::array unnecessary.

Aucun commentaire:

Enregistrer un commentaire