MeshLib C# Docs
Loading...
Searching...
No Matches
MR.Misc.Const_Box< T > Class Template Reference

Stores a single heap-allocated value with a stable address, or a user-provided non-owning pointer. This is used for class fields of pointer types to const non-classes. Usage: More...

+ Inheritance diagram for MR.Misc.Const_Box< T >:

Public Member Functions

unsafe Const_Box (T value)
 Allocate a new value.
 
unsafe Const_Box (T *ptr)
 Store a non-owning pointer.
 
virtual void Dispose ()
 
- Public Member Functions inherited from MR.Misc.KeepAliveHolder< Const_Box< T > >
void _KeepAlive (object obj, string key="")
 Keeps obj alive as long as this object exists. If key is specified, it's an optional tag for this object.
 
void _DiscardKeepAlive (string key="")
 Discards the objects kept alive by this object. If key is not empty, only discards the objects with the same key. Otherwise discards all of them. This intentionally doesn't discard _KeepAliveEnclosingObject.
 

Static Public Member Functions

static implicit operator Const_Box< T > (T value)
 Implicitly convert from a value, allocating a copy of it. Only Const_Box<T> has this, Box<T> intentionally doesn't.
 
- Static Public Member Functions inherited from MR.Misc.KeepAliveHolder< Const_Box< T > >
static void _StaticKeepAlive (object obj, string key="")
 
static void _StaticDiscardKeepAlive (string key="")
 

Protected Member Functions

virtual unsafe void Dispose (bool disposing)
 

Properties

unsafe ref readonly T Value [get]
 
bool IsOwning [get]
 

Additional Inherited Members

- Public Attributes inherited from MR.Misc.KeepAliveHolder< Const_Box< T > >
object? _KeepAliveEnclosingObject
 A special holder for the enclosing object when returning a reference to its subobject.
 

Detailed Description

Stores a single heap-allocated value with a stable address, or a user-provided non-owning pointer. This is used for class fields of pointer types to const non-classes. Usage:

  • To read a property of type Const_Box<T>?, first check is not null. If it's not null, use .Value to read the value.
  • To modify the property, either assign a value of type T, or assign null. Assigning a value will allocate its copy and make the underlying pointer point to it.
Type Constraints
T :unmanaged 

The documentation for this class was generated from the following file: