.NET introduces Span<T>, basically D slices

Ola Fosheim Grøstad ola.fosheim.grostad+dlang at gmail.com
Sun Nov 19 22:30:35 UTC 2017


On Sunday, 19 November 2017 at 14:46:32 UTC, Rumbu wrote:
> Sorry to disappoint, but Span<T> is something else. The .net 
> equivalent of D slices is in fact the not so popular 
> ArraySegment<T> available in .net since 2008.
>
> Span<T> will allow access to unmanaged and stack memory in the 
> same way as using a standard array.

Seems to be a C# version of C++ gsl::span:

https://github.com/Microsoft/GSL/blob/master/include/gsl/span

But yes, as I understand it, it will only allow shrinking the 
view, so it is a proper pointer-like type with sub-typing like 
behaviour. It might appear in C++20 as array_view eventually… not 
sure.


More information about the Digitalmars-d mailing list