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
TThe unmanaged type of the value to which the pointer refers.
- Implements
-
IEquatable<UniquePtr<T>>
- 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
valueT*
Methods
Attach(T*)
public void Attach(T* value)
Parameters
valueT*
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
otherUniquePtr<T>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
Returns
implicit operator T*(UniquePtr<T>)
public static implicit operator T*(UniquePtr<T> ptr)
Parameters
ptrUniquePtr<T>
Returns
- T*
implicit operator UniquePtr<T>(T*)
public static implicit operator UniquePtr<T>(T* value)
Parameters
valueT*
Returns
- UniquePtr<T>
operator !=(UniquePtr<T>, UniquePtr<T>)
public static bool operator !=(UniquePtr<T> left, UniquePtr<T> right)