CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
System::Memory< T > Class Template Reference

Represents a mutable memory segment backed by an array. More...

#include <memory.h>

Inherits System::Details::MemoryCore< T >.

Public Member Functions

Span< T > get_Span () const
 Gets a span that represents the current memory. More...
 
void CopyTo (const Memory &destination)
 Copies the contents of this memory to the destination memory. More...
 
bool TryCopyTo (const Memory &destination)
 Attempts to copy the contents of this memory to the destination memory. More...
 
Memory Slice (int32_t start, int32_t length) const
 Creates a slice of the current memory. More...
 
 operator ReadOnlyMemory< T > () const
 Implicitly converts Memory to ReadOnlyMemory. More...
 
template<typename T1 = T>
std::enable_if< std::is_same< T1, char16_t >::value, String >::type ToString () const
 Converts the character memory to a string representation. More...
 
template<typename T1 = T>
std::enable_if<!std::is_same< T1, char16_t >::value, String >::type ToString () const
 Converts the ordinary memory to a string representation. More...
 

Static Public Member Functions

static Memory get_Empty ()
 Gets an empty Memory instance. More...
 
static Memory to_Memory (const ArrayPtr< T > &array)
 Creates a Memory instance from the specified array. More...
 

Detailed Description

template<typename T>
class System::Memory< T >

Represents a mutable memory segment backed by an array.

Exposes a span over the array region and supports slicing and copying.

Member Function Documentation

◆ CopyTo()

template<typename T >
void System::Memory< T >::CopyTo ( const Memory< T > &  destination)
inline

Copies the contents of this memory to the destination memory.

Parameters
destinationThe destination memory segment.

◆ get_Empty()

template<typename T >
static Memory System::Memory< T >::get_Empty ( )
inlinestatic

Gets an empty Memory instance.

Returns
An empty Memory object.

◆ get_Span()

template<typename T >
Span< T > System::Memory< T >::get_Span ( ) const
inline

Gets a span that represents the current memory.

Returns
A span over the memory segment.

◆ operator ReadOnlyMemory< T >()

template<typename T >
System::Memory< T >::operator ReadOnlyMemory< T > ( ) const
inline

Implicitly converts Memory to ReadOnlyMemory.

Returns
A ReadOnlyMemory object that represents the same memory segment.

◆ Slice()

template<typename T >
Memory System::Memory< T >::Slice ( int32_t  start,
int32_t  length 
) const
inline

Creates a slice of the current memory.

Parameters
startThe starting index of the slice.
lengthThe number of elements in the slice.
Returns
A Memory object representing the requested slice.

◆ to_Memory()

template<typename T >
static Memory System::Memory< T >::to_Memory ( const ArrayPtr< T > &  array)
inlinestatic

Creates a Memory instance from the specified array.

Parameters
arrayThe source array.
Returns
A Memory object that wraps the array.

◆ ToString() [1/2]

template<typename T >
template<typename T1 = T>
std::enable_if< std::is_same< T1, char16_t >::value, String >::type System::Memory< T >::ToString ( ) const
inline

Converts the character memory to a string representation.

Returns
A string representing the memory.

◆ ToString() [2/2]

template<typename T >
template<typename T1 = T>
std::enable_if<!std::is_same< T1, char16_t >::value, String >::type System::Memory< T >::ToString ( ) const
inline

Converts the ordinary memory to a string representation.

Returns
A string representing the memory.

◆ TryCopyTo()

template<typename T >
bool System::Memory< T >::TryCopyTo ( const Memory< T > &  destination)
inline

Attempts to copy the contents of this memory to the destination memory.

Parameters
destinationThe destination memory segment.
Returns
True if the copy succeeded; otherwise, false.