Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to std::cspan?

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?

like image 509
Indiana Kernick Avatar asked Jul 02 '19 05:07

Indiana Kernick


Video Answer


1 Answers

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.

like image 86
Barry Avatar answered Oct 07 '22 03:10

Barry