using System;
using System.Runtime.CompilerServices;
namespace ComputeSharp.Core.NetStandard.System.Runtime.InteropServices;
///
/// A polyfill type that mirrors some methods from on .NET 6.
///
internal static class MemoryMarshal
{
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetReference(Span span)
{
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetReference(ReadOnlySpan span)
{
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
}
///
/// Creates a new from a given reference.
///
/// The type of reference to wrap.
/// The target reference.
/// The length of the to create.
/// A new wrapping .
public static unsafe Span CreateSpan(ref T value, int length)
{
return new(Unsafe.AsPointer(ref value), length);
}
}