Add support for copying from Vector<T> to Span<T> #29929
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Numerics
Milestone
Currently
Vector<T>
can be constructed from aSpan<T>
, but writing the result of a vectorized operation into aSpan<T>
is impossible, since theVector<T>.CopyTo
method lacks the necessary overload.Rationale and usage
The following code computes the sum of two arrays using SIMD operations and stores it in the
trgt
parameter.Converting this code to accept
Span<double>
instead ofdouble[]
makes sense, for example to support operation on slices of arrays or on external memory. A first conversion attempt leads to the following code.However, this fails to compile since
Vector<double>.CopyTo(Span<double> x)
does not exist.Propsed API
Extend
Vector<T>
as follows.Details
Vector<T>
from aSpan<T>
has been added in Issue #24343 Vector Ctor using Span corefx#26499, but without the ability to get the result back out into aSpan<T>
the usability of this feature is limited.The text was updated successfully, but these errors were encountered: