CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
memory_marshal.h
1
2#pragma once
3
4#include <system/span.h>
5
6namespace System { namespace Runtime { namespace InteropServices {
7
13{
14public:
16 template<typename T>
17 static Span<uint8_t> AsBytes(const Span<T>& span)
18 {
19 return Span<uint8_t>(span.data_ptr(), span.get_Length() * sizeof(T));
20 }
21
23 template <typename TFrom, typename TTo>
24 static Span<TTo> Cast(const Span<TFrom>& span)
25 {
26 return Span<TTo>((TTo*)span.data_ptr(), span.get_Length() * sizeof(TFrom) / sizeof(TTo));
27 }
28};
29
30}}} // namespace System::Runtime::InteropServices
Provides memory marshalling implementation. For compatibility with translated code only,...
Definition: memory_marshal.h:13
static Span< TTo > Cast(const Span< TFrom > &span)
Casts a Span of one primitive type TFrom to another primitive type TTo.
Definition: memory_marshal.h:24
static Span< uint8_t > AsBytes(const Span< T > &span)
Casts a Span of one primitive type T to Span of bytes.
Definition: memory_marshal.h:17
Represents a contiguous region of arbitrary memory similar to C++20's std::span.
Definition: span.h:364
Definition: db_command.h:9