std::span has been voted into C++20. I assumed that along with std::span, there would be a convenience alias defined like this:
template <class T, size_t Extent = dynamic_extent>
using cspan = span<const T, Extent>;
To me, this seems like a really handy alias. I'd probably use cspan more often than span! According to cppreference, cspan doesn't exist. There's one mention of cspan in this paper which seems to imply that it was in the standard at some point. I can't find any other mentions.
So what happened to cspan? Was it removed? Did it ever exist at all?
Indeed, cspan does not exist and has never existed. The only name change is that span used to be spelled array_view
The reference in P1085R2:
| 3 | Make span operate only on const T, (rename cspan, obviously :D) |
is a joke, as implied by the :D (note that C-SPAN is a cable network that broadcasts federal government proceedings). The actual proposal was that span<T> change to behave like today's span<T const> (and cheekily be renamed to cspan).
Just write span<T const>. It's a full 5 characters longer than cspan<T>, with the added benefit that more people will know what span is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With