struct Box
Box is a generic container for objects (both value and heap), allowing the user to box them in a generic form and recover them later.
TypeInfo type
Property for the type contained by the box. This is initially null and cannot be assigned directly.
void* data
Property for the data pointer to the value of the box. This is initially null and cannot be assigned directly.
bit unboxable(TypeInfo type)
Return whether the value could be unboxed as the given type without throwing an error.
char[ toString()
Attempt to convert the boxed value into a string using std.string.format; this will throw if that function cannot handle it. If the box is uninitialized then this returns "".
bit opEquals(Box other)
Compare this box's value with another box. This implicitly casts if the types are different, identical to the regular type system.
float opCmp(Box other)
Compare this box's value with another box. This implicitly casts if the types are different, identical to the regular type system.
uint toHash()
Return the value's hash.
Box box(...)
Box the single argument passed to the function. If more or fewer than one argument is passed, this will assert.
Box box(TypeInfo type, void* data)
Box the explicitly-defined object. type must not be null; data must not be null if the type's size is greater than zero.
Box[ boxArray(TypeInfo[ types, void* data)
Box[ boxArray(...)
Convert a list of arguments into a list of boxes.
void boxArrayToArguments(Box[ arguments, out TypeInfo[ types, out void* data)
Convert a list of boxes into a list of arguments.
bit unboxable!(T)(Box value)
Return whether the value can be unboxed as the given type; if this returns false, attempting to do so will throw UnboxException.
T unbox!(T)(Box value)
This template function converts a boxed value into the provided type. To use it, instantiate the template with the desired result type, and then call the function with the box to convert.
This will implicitly cast base types as necessary and in a way consistent with static types - for example, it will cast a boxed byte into int, but it won't cast a boxed float into short. If it cannot cast, it throws UnboxException.
|