mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Third time lucky
This is my test code. var sourceArr = scope int[10] (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var destArr = scope int[10]; var detSpan = Span<int>(destArr, 0, 5); sourceArr.CopyTo(detSpan, 2); // destArr holds 3, 4, 5
This commit is contained in:
parent
dd33da0d7c
commit
d9c277389e
1 changed files with 6 additions and 4 deletions
|
@ -270,16 +270,18 @@ namespace System
|
|||
|
||||
public void CopyTo(Span<T> destination)
|
||||
{
|
||||
Debug.Assert(destination.Length >= mLength);
|
||||
Debug.Assert(destination.[Friend]mPtr != null);
|
||||
Debug.Assert(destination.[Friend]mLength >= mLength);
|
||||
|
||||
Internal.MemCpy(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T));
|
||||
}
|
||||
|
||||
public void CopyTo(Span<T> destination, int srcOffset)
|
||||
{
|
||||
Debug.Assert(destination.Length >= mLength);
|
||||
Debug.Assert((uint)srcOffset <= (uint)mLength);
|
||||
Debug.Assert(destination.[Friend]mPtr != null);
|
||||
Debug.Assert((uint)destination.[Friend]mLength - (uint)srcOffset < (uint)mLength);
|
||||
|
||||
Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * (mLength - srcOffset), alignof(T));
|
||||
Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * (destination.Length - srcOffset), alignof(T));
|
||||
}
|
||||
|
||||
public Span<T>.Enumerator GetEnumerator()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue