Table of Contents

Struct UniquePtr<T>

Namespace
Misaki.HighPerformance.LowLevel
Assembly
Misaki.HighPerformance.LowLevel.dll

Provides exclusive ownership and management of an unmanaged pointer to a value of type T. Ensures that the pointer is not shared and can be safely transferred or detached.

public struct UniquePtr<T> : IEquatable<UniquePtr<T>> where T : unmanaged

Type Parameters

T

The unmanaged type of the value to which the pointer refers.

Implements
Inherited Members

Remarks

UniquePtr<T> is designed to encapsulate a raw pointer, enforcing unique ownership semantics similar to C++'s std::unique_ptr.

Constructors

UniquePtr(T*)

public UniquePtr(T* value)

Parameters

value T*

Methods

Attach(T*)

public void Attach(T* value)

Parameters

value T*

Detach()

public T* Detach()

Returns

T*

Equals(UniquePtr<T>)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(UniquePtr<T> other)

Parameters

other UniquePtr<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Get()

public readonly T* Get()

Returns

T*

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetRef()

public ref T GetRef()

Returns

T

Share()

public readonly SharedPtr<T> Share()

Returns

SharedPtr<T>

Operators

operator ==(UniquePtr<T>, UniquePtr<T>)

public static bool operator ==(UniquePtr<T> left, UniquePtr<T> right)

Parameters

left UniquePtr<T>
right UniquePtr<T>

Returns

bool

implicit operator T*(UniquePtr<T>)

public static implicit operator T*(UniquePtr<T> ptr)

Parameters

ptr UniquePtr<T>

Returns

T*

implicit operator UniquePtr<T>(T*)

public static implicit operator UniquePtr<T>(T* value)

Parameters

value T*

Returns

UniquePtr<T>

operator !=(UniquePtr<T>, UniquePtr<T>)

public static bool operator !=(UniquePtr<T> left, UniquePtr<T> right)

Parameters

left UniquePtr<T>
right UniquePtr<T>

Returns

bool