In several recent conference presentation I've heard Bjarne Stroustrup and others mention new coding guidelines for C++ and some types supporting them.
Specifically, I remember the example of span<T>
instead of (T* p, int n)
as a parameter to a function (at time about 32:00 into the talk); but I also remember the suggestion to use array_view<T>
. Are they two alternatives but the same concept? Or am I confusing things and they're actually not so related?
I can't seem to find any authoritative definition of what they're both supposed to be about.
The document P0122R (2016-02-12) from the Library Evolution Working Group (LEWG)
officially renames the type
array_view
tospan
:We can also read:
In a next chapter, this documents presents the read-only and read-write (mutable) accesses:
See also the Guidelines Support Library Review:
span<T>
from Marius Bancila (march 2016) definingspan
as:In the CppCoreGuidlines The original
array_view
was renamed tospan
.See: https://github.com/isocpp/CppCoreGuidelines/pull/377
It is described thus:
We talked with people in the library working group in the standards committee. They wanted the
array_view
they are trying to get into the standard to be read only. For the core guidelines, we needed an abstraction that was read and write. To avoid a clash between the (potential) standards and the guidelines support library (GSL), we renamed our (read and write)array_view
tospan
: https://github.com/microsoft/gsl .