Struct Pointer<T>
Represents a non-nullable transient pointer pointing to a target of type T.
Inherited Members
Namespace: SemPtr
Assembly: SemPtr.dll
Syntax
public readonly ref struct Pointer<T> : ITypedPointer<T, Pointer<T>>, ITypedPointer<T>, IPointer<Pointer<T>>, IPointer, IEquatable<Pointer<T>>, IEquatable<NullablePointerReadOnly>, IEquatable<NullablePointerUninitialized>, IEquatable<NullableFunctionPointer>, ISpanFormattable, IFormattable, IUtf8SpanFormattable where T : unmanaged, allows ref struct
Type Parameters
| Name | Description |
|---|---|
| T | The type of the target that the pointer points to. |
Remarks
Pointer<T> has the following characteristics:
- Non-
nullableYou can access the pointer's target directly without checking fornull. - TransientThe pointer's target is only valid for the lifetime of the pointer. You cannot let the pointer escape the current scope and you cannot access the pointer's target after the pointer's lifetime ends.
- Single objectThe pointer points to a single target. You can only access that target directly. You cannot perform pointer arithmetic with the pointer.
- Read-writeYou can read and write the pointer's target.
- TypedThe pointer points to a single target of type
T.
You should never create instances of Pointer<T> using its parameterless constructors or default(Pointer<T>). Doing so will result in undefined behavior.
Always use the FromRaw(T*), FromIntPtr(nint), or FromUIntPtr(nuint) methods to create instances of Pointer<T> pointers.
Constructors
| Name | Description |
|---|---|
| Pointer() | Do not use. Do not create instances of non-nullable pointers using parameterless constructors or default values. |
Properties
| Name | Description |
|---|---|
| AsIntPtr | Gets an nint that represents the same memory address as the current pointer. |
| AsUIntPtr | Gets an nuint that represents the same memory address as the current pointer. |
| HasTarget | Gets a value indicating whether the current pointer is non- |
| Raw | Gets a raw pointer pointing to the same target as the current pointer. |
| Target | Gets a reference to the target value the current pointer is pointing to. |
Methods
| Name | Description |
|---|---|
| Equals(NullableFunctionPointer) | Indicates whether the current object is equal to another object of the same type. |
| Equals(NullablePointerReadOnly) | Indicates whether the current object is equal to another object of the same type. |
| Equals(NullablePointerUninitialized) | Indicates whether the current object is equal to another object of the same type. |
| Equals(Pointer<T>) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Not supported. Do not call this method, use the Equals(Pointer<T>) method instead. |
| FromIntPtr(nint) | Creates a Pointer<T> from a memory address given as a nint. |
| FromRaw(T*) | Creates a Pointer<T> from a |
| FromUIntPtr(nuint) | Creates a Pointer<T> from a memory address given as a nint. |
| GetHashCode() | Returns the hash code for this instance. |
| ToString() | Formats the value of the current instance using the default format. |
| ToString(IFormatProvider?) | Formats the value of the current instance using the specified format. |
| ToString(string?) | Formats the value of the current instance using the specified format. |
| ToString(string?, IFormatProvider?) | Formats the value of the current instance using the specified format. |
| TryFormat(Span<byte>, out int, IFormatProvider?) | Tries to format the value of the current instance as UTF-8 into the provided span of bytes. |
| TryFormat(Span<byte>, out int, ReadOnlySpan<char>, IFormatProvider?) | Tries to format the value of the current instance as UTF-8 into the provided span of bytes. |
| TryFormat(Span<char>, out int, IFormatProvider?) | Tries to format the value of the current instance into the provided span of characters. |
| TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?) | Tries to format the value of the current instance into the provided span of characters. |