Reputation:
I've been updating old code that used my homebrew span class to the one that is more in line with C++20 std::span
and I'm getting compile errors because std::span
doesn't have size_type
and instead has index_type
. There's been a huge drama over whether index_type
should be signed or not, but why skipping size_type
? This breaks generic code that expects containers (or container-like objects) to have size_type
.
Upvotes: 9
Views: 1021
Reputation: 4863
The original proposal P1022R0, back when it was called array_view
, had a size_type
member. It was removed in the first revision P1022R1 as part of the simplification, as it wasn't needed because size()
and element access were, at that time, using the signed index_type
(aka ptrdiff_t
). At the Kona 2019 meeting, that decision was changed in P1227R2 by changing index_type
to be size_t
.
Upvotes: 5