Subject: Re: [std-proposals] std::span<T> should be size_type NOT index_type.
From: Arthur O'Dwyer (arthur.j.odwyer_at_[hidden])
Date: 2019-05-13 10:06:00
sotrdg sotrdg writes:
> Please change it to size_type just like other containers!!!! I hate the
What other STL types have an `index_type`? (None AFAICT.)
What other STL types have a `size_type`? (Containers, allocators,
std::string, std::array, and std::string_view, AFAICT.)
The fact that `std::string_view` â also "not a container" â has `size_type`
and not `index_type` is compelling to me, in the absence of any other data
I speculate that what happened here may have been the result of several
overlapping compromises related to the "signed size_type" controversy. That
is, span may have started out with a signed `size_type` alias, and then
people objected to that, so it was changed to a signed `index_type` alias
leaving room for an unsigned `size_type` to be added later, and then people
still objected to that, so it was changed to an unsigned `index_type`; but
it has not yet completed the circle back to the traditional unsigned
I see that P0122R0
("array_view") had both unsigned size_type and strangely-typed index_type,
but by R1 ("span") it had evolved to a plain old signed index_type and no
size_type at all.
*I suggest that someone write a paper renaming index_type to size_type.*
I'm cc'ing the author of P1024R3
last touched std::span AFAIK) and the authors of P0122R7
introduced the std::span with a signed index_type and no size_type) in case
they have additional information.
On Sun, May 12, 2019 at 6:15 PM Lyberta via Std-Proposals <
> Timur Doumler via Std-Proposals:
> > std::span is not a container.
> > Cheers,
> > Timur
> But not having size_type break templates that don't take ownership the
> the container and would otherwise be happy with std::span. I think
> having size_type vs index_type duality does nothing good.
> If we want people to take containers then add Container concept to the
> standard library.
> Std-Proposals mailing list
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups