ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
Box Class Reference

Description:

This is the central class of ALib Boxing . By using template meta programming, an object of this class can be created by passing just any C++ type to the constructor. The passed value will be "boxed" within the instance of this class.

Then, the instances of this class support type checking, value extraction ("unboxing") and the invocation of "virtual methods". All features are customizable in detail per "boxable type".

A thorough introduction to and documentation of all aspects of ALib Boxing is given with Programmer's Manual ALib Boxing.

Functors In Namespace std

Functors std::hash, std::equal_to and std::less are specialized for this type with the inclusion of header file alib/compatibility/std_boxing_functional.hpp as documented with namespace alib::compatibility::std.

Definition at line 38 of file box.inl.

Inheritance diagram for Box:
[legend]
Collaboration diagram for Box:
[legend]

Public Type Index:

using TypeCode = uinteger
 The type of type codes received with ExportType.
 

Public Method Index:

 Box () noexcept
 
 Box (Box &&) noexcept=default
 Trivial default move constructor.
 
 Box (const Box &) noexcept=default
 Trivial default copy constructor.
 
template<typename TBoxable >
constexpr Box (const TBoxable &src) noexcept
 
 Box (TypeCode typeCode, const Placeholder &placeholder) noexcept
 
 ~Box () noexcept=default
 Trivial default destructor.
 
size_t ArrayElementSize () const
 
template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call (TArgs &&... args)
 
template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call (TArgs &&... args) const
 
template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) CallDirect (typename TFDecl::Signature function, TArgs &&... args)
 
template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) CallDirect (typename TFDecl::Signature function, TArgs &&... args) const
 
ALIB_API void Clone (MonoAllocator &memory)
 
PlaceholderData ()
 
const PlaceholderData () const
 
const detail::VTableDbgGetVTable () const
 
const std::type_info & ElementTypeID () const
 
TypeCode ExportType () const
 
Placeholder ExportValue () const
 
template<typename TFDecl >
TFDecl::Signature GetFunction (Reach searchScope, bool isInvocation=false) const
 
unsigned int GetPlaceholderUsageLength () const
 
ALIB_API size_t Hashcode () const
 
void Import (TypeCode typeCode)
 
void Import (TypeCode typeCode, const Placeholder &placeholder)
 
bool IsArray () const
 
template<typename TElementType >
bool IsArrayOf () const
 
bool IsCharacter () const
 
bool IsEnum () const
 
bool IsFloatingPoint () const
 
ALIB_API bool IsNotNull () const
 
bool IsNull () const
 
bool IsPointer () const
 
bool IsSameType (const Box &other) const
 
bool IsSignedIntegral () const
 
template<typename TBoxable >
bool IsType () const
 
bool IsUnsignedIntegral () const
 
ALIB_API operator bool () const
 
bool operator!= (const Box &rhs) const
 
ALIB_API bool operator< (Box const &rhs) const
 
ALIB_API bool operator<= (Box const &rhs) const
 
Boxoperator= (Box &&) noexcept=default
 
Boxoperator= (const Box &) noexcept=default
 
ALIB_API bool operator== (Box const &rhs) const
 
ALIB_API bool operator> (Box const &rhs) const
 
bool operator>= (Box const &rhs) const
 
const std::type_info & TypeID () const
 
template<typename TUnboxable >
const TUnboxable Unbox () const
 
template<typename TElementType >
TElementType * UnboxArray () const
 
wchar UnboxCharacter () const
 
template<typename TElementType >
TElementType & UnboxElement (integer idx) const
 
ALIB_API double UnboxFloatingPoint () const
 
integer UnboxLength () const
 
template<typename TUnboxable >
TUnboxable UnboxMutable () const
 
integer UnboxSignedIntegral () const
 
uinteger UnboxUnsignedIntegral () const
 

Protected Static Method Index:

template<typename TBoxable , bool NoStaticAsserts = false>
static detail::VTablegetVTable ()
 

Protected Field Index:

Placeholder data
 The data that we encapsulate.
 
detail::VTablevtable
 

Type Definition Details:

◆ TypeCode

using TypeCode = uinteger

The type of type codes received with ExportType.

Definition at line 226 of file box.inl.

Field Details:

◆ data

Placeholder data
protected

The data that we encapsulate.

Definition at line 50 of file box.inl.

◆ vtable

detail::VTable* vtable
protected

The singleton of a class derived from class VTable which defines our type and behavior.

Definition at line 47 of file box.inl.

Constructor(s) / Destructor Details:

◆ Box() [1/3]

Box ( )
inlinenoexcept

Default constructor.
After creation with this constructor, a call to IsType<void> returns true. To reset an instance previously used, assign keyword nullptr.

Definition at line 233 of file box.inl.

◆ Box() [2/3]

Box ( TypeCode typeCode,
const Placeholder & placeholder )
inlinenoexcept

Constructor accepting previously exported values.

Parameters
typeCodeThe type code this box will be set to.
placeholderThe data this box will be set to.

Definition at line 268 of file box.inl.

◆ Box() [3/3]

template<typename TBoxable >
Box ( const TBoxable & src)
inlineconstexprnoexcept

Constructor using template meta programming to fetch any type of C++ value.
Internally, this constructor is implemented using a set of different constructors which are selected by the compiler using std::enable_if conditions.

Types derived from class Box itself are boxed by coping the internal values of the box. This means, that boxing objects of derived types is similar to "downcasting" the object to class Box.

Template Parameters
TBoxableAny C++ type to be boxed.
Parameters
srcThe src value or pointer type T.

Method Details:

◆ ArrayElementSize()

size_t ArrayElementSize ( ) const
inline

Returns the size in bytes of on element of the stored array. For non-array types, 0 is returned.

Returns
The size of elements in the array.

Definition at line 968 of file box.inl.

◆ Call() [1/2]

template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call ( TArgs &&... args)
inline

Same as method Call, but usable with interfaces that only accept a mutable (aka not constant) box. Technically, the only difference between this method and Call is that the latter is declared const.

Note
The only built-in boxing function that requires a mutable reference to a box, is function FClone. This modifies the contents of a box by performing deep copies, with the goal to extent the lifecylce of boxes.
Template Parameters
TFDeclThe function type to call. Has to be explicitly specified.
TArgsTypes of the variadic arguments args. Do not need to be specified.
Parameters
argsVariadic arguments forwarded to the function.
Returns
Nothing in case that TReturn is void, otherwise the result of the invocation, respectively TReturn() if the requested function type was not found for this Box.

Definition at line 1229 of file box.inl.

Here is the call graph for this function:

◆ Call() [2/2]

template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call ( TArgs &&... args) const
inline

Invokes a function registered for boxes of the mapped type. The function declaration is provided with the first template parameter TFDecl. The further variadic template parameters do not need to be specified. They specify the types of the called function's parameters and are matched against the function signature given with the declaration. If the types of the given function arguments do not correspond to the types of the box-function called, a compile-time error is raised.

Note
Precisely, the variadic template types denote the function arguments starting from the second, as the first argument is always a reference to the box that this method was invoked on.

If no corresponding function was registered for the mapped type, then a default function, that is applicable to any mapped type is searched. If neither is found, a default value of the return type of the function is returned.

With debug-builds, an assertion is raised if the function type is not known at all to ALib Boxing. This is true, if an implementation was neither registered with any other mapped type, nor registered as a default.

See also
Description of method GetFunction to implement two use cases:
  • Repetitive invocation of the same function.
  • Avoidance of default functions
A non-constant overload exists, for the seldom case the reference to this box that is passed to the function, needs to be of non-constant type.
Template Parameters
TFDeclThe function type to call. Has to be explicitly specified.
TArgsTypes of the variadic arguments args. Do not need to be specified.
Parameters
argsVariadic arguments forwarded to the function.
Returns
Nothing in case that TReturn is void, otherwise the result of the invocation, respectively TReturn() if the requested function type was not found for this Box.

Definition at line 1175 of file box.inl.

Here is the call graph for this function:

◆ CallDirect() [1/2]

template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) CallDirect ( typename TFDecl::Signature function,
TArgs &&... args )
inline

Alternative version of non-constant version of method Call, which accepts the function's pointer as a first argument. Such pointer can be received upfront with method GetFunction.

Template Parameters
TFDeclThe function type to call. Has to be explicitly specified.
TArgsTypes of the variadic arguments args. Do not need to be specified.
Parameters
argsVariadic arguments forwarded to the function.
functionThe function to invoke.
Returns
Nothing in case that TReturn is void, otherwise the result of the invocation, respectively TReturn() if the requested function type was not found for this Box.

Definition at line 1257 of file box.inl.

◆ CallDirect() [2/2]

template<typename TFDecl , typename... TArgs>
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) CallDirect ( typename TFDecl::Signature function,
TArgs &&... args ) const
inline

Alternative version of method Call, which accepts the function's pointer as a first argument. Such pointer can be received upfront with method GetFunction.

Template Parameters
TFDeclThe function type to call. Has to be explicitly specified.
TArgsTypes of the variadic arguments args. Do not need to be specified.
Parameters
argsVariadic arguments forwarded to the function.
functionThe function to invoke.
Returns
Nothing in case that TReturn is void, otherwise the result of the invocation, respectively TReturn() if the requested function type was not found for this Box.

Definition at line 1201 of file box.inl.

◆ Clone()

ALIB_API void Clone ( MonoAllocator & memory)

Returns the result of invocation of built-in boxing function FHashcode.

Availability
This method is available only if the module ALib Monomem is included in the ALib Distribution.
Parameters
memoryA monotonic allocator used for storing cloned data.

◆ Data() [1/2]

Placeholder & Data ( )
inline

Non-constant variant of Data, that allows write access to the internal memory of this box.

A use case for non-constant access could be the implementation of a non-constant box-function. In fact, this is the only occasion where within any ALib Module this method was needed.

Returns
The raw contents of this box.

Definition at line 861 of file box.inl.

◆ Data() [2/2]

const Placeholder & Data ( ) const
inline

Returns the "raw" placeholder of this box.

In some special situations, this method might be used inspect into the boxed data and "reinterpret" its contents in a custom way.

Returns
The raw contents of this box.

Definition at line 844 of file box.inl.

◆ DbgGetVTable()

const detail::VTable * DbgGetVTable ( ) const
inline

Returns the vtable of this instance that is associated with the currently boxed type.
Available only with debug-builds.

See also
Manual chapter 12.7 Debug Helpers of the Programmer's Manual.
Returns
The vtable of this instance.

Definition at line 510 of file box.inl.

◆ ElementTypeID()

const std::type_info & ElementTypeID ( ) const
inline

Returns the std::type_info struct describing the element type of mapped array types.

Note
This method is provided for "completeness" and only be used in special situations.
In case this box is not of array type, typeid(void) is returned.
Returns
The std::type_info of the mapped type.

Definition at line 956 of file box.inl.

◆ ExportType()

TypeCode ExportType ( ) const
inline

Returns the type of this box as an integral value. This value might be stored and used to compare types of boxes later.

Returns
An identifier of type of this box.

Definition at line 889 of file box.inl.

◆ ExportValue()

Placeholder ExportValue ( ) const
inline

Returns the type of this box as an integral value. This value might be stored and used to compare types of boxes later.

Note
This method is provided for "completeness" and only be used in special situations.
If a box is not initialized (or has nullptr assigned, 0 is returned.
Returns
An identifier of type of this box.

Definition at line 900 of file box.inl.

◆ GetFunction()

template<typename TFDecl >
TFDecl::Signature GetFunction ( Reach searchScope,
bool isInvocation = false ) const
inline

Searches an implementation of a box-function identified by template parameter TFDecl, which has to be implemented according the rules of function declarations.
If found, a non-nulled function pointer is returned, otherwise a nulled one.

On success, the function can be invoked by passing the returned pointer to method CallDirect. This approach avoids further searches that are otherwise to be performed with multiple invocations of method Call.

If parameter defaults equals Reach::Local, functions specific to the mapped type of this box (registered using BootstrapRegister) are searched. If Reach::Global is given, then a defaulted function (registered using BootstrapRegisterDefault) is searched, if no specific function was found.

Note
Reach::Local can be used to detect specific behavior and to avoid the use of default functions. This can be useful if the default implementation of a function is just not applicable in a certain situation.
A second use case of this method are situations where multiple invocations of the same function are to be done, on just one or on several boxes of the same mapped type:
 assert( box1.IsSameType( box2 ) );

 auto* func= box1.GetFunction<FMyFunc>( Reach::Global );
 if( func != nullptr )
     for( int i= 0; i< 10; ++i )
     {
         box1.CallDirect<FMyFunc>( func, i );
         box2.CallDirect<FMyFunc>( func, i );
     }
Template Parameters
TFDeclThe function declaration to search for.
Parameters
searchScopeReach::Local chooses type-specific functions only, while. Reach::Global includes default functions in the search.
isInvocationAvailable only in debug compilations. If true, a counter associated with an implementation found is increaed to provide statistics. Defaults to false and should not be given.
Returns
The function implementation. nullptr in case that no function is available.

◆ GetPlaceholderUsageLength()

unsigned int GetPlaceholderUsageLength ( ) const
inline

Returns the number of relevant bytes used in the placeholder.

This method is used with default implementations of box-functions FHashcode and FEquals.

See also
The documentation of TMP struct T_SizeInPlaceholder provides details on and rationals for the existence of this method.
Returns
The raw contents of this box.

Definition at line 879 of file box.inl.

◆ getVTable()

template<typename TBoxable , bool NoStaticAsserts = false>
static detail::VTable * getVTable ( )
inlinestaticprotected

Shortcut inline method to retrieve the vtable singleton for the template type. In debug-compilations, the received vtable is checked for being registered.

Template Parameters
TBoxableThe source type to receive the vtable for.
Returns
The vtable singleton.

◆ Hashcode()

size_t Hashcode ( ) const

Returns the result of invocation of built-in boxing function FHashcode.

Returns
A hashcode for the boxed type and value.

Definition at line 163 of file boxing.cpp.

Here is the call graph for this function:

◆ Import() [1/2]

void Import ( TypeCode typeCode)
inline

Changes this box to use the given type code previously exported with ExportType. The value of this box will be set to 0.

Parameters
typeCodeThe type code this box will be set to.

Definition at line 905 of file box.inl.

Here is the call graph for this function:

◆ Import() [2/2]

void Import ( TypeCode typeCode,
const Placeholder & placeholder )
inline

Changes this box to use the given type and data, previously received with methods ExportType and ExportValue.

Parameters
typeCodeThe type code this box will be set to.
placeholderThe data this box will be set to.

Definition at line 917 of file box.inl.

◆ IsArray()

bool IsArray ( ) const
inline

Returns true if this box represents an array of objects. In this case, method UnboxLength (usually) will return the length of the array and UnboxElement may be used to access elements of the array.

Returns
true if this box represents an array, false otherwise.

Definition at line 712 of file box.inl.

Here is the call graph for this function:

◆ IsArrayOf()

template<typename TElementType >
bool IsArrayOf ( ) const
inline

Returns true if this objects represents an array and the element type equals template parameter TElementType.

Template Parameters
TElementTypeThe array element type to compare our element type with.
Returns
true if this box represents an array of given type, false otherwise.

Definition at line 725 of file box.inl.

◆ IsCharacter()

bool IsCharacter ( ) const
inline

Tests if this box contains one of types char, wchar_t, char16_t or char32_t.

With default library compilation that disables symbol ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS, this method will be inlined and simply returns IsType<wchar>().
Otherwise this method will not be inlined and tests for all four different character types.

Returns
true if this box contains a character type, false otherwise.

Definition at line 652 of file box.inl.

Here is the call graph for this function:

◆ IsEnum()

bool IsEnum ( ) const
inline

Returns true if this box contains an element of a scoped or non-scoped enum type. Enum element values are always boxed as type integer stored in union field Placeholder.

Returns
true if this box contains an object boxed as pointer type, false otherwise.

Definition at line 749 of file box.inl.

Here is the call graph for this function:

◆ IsFloatingPoint()

bool IsFloatingPoint ( ) const

Tests if this box contains a floating point type.

Note
If ALIB_FEAT_BOXING_BIJECTIVE_FLOATS is not set, this method will test against double and long double. If it is set, in addition type float is tested.
Returns
true if this box contains a floating point type, false otherwise.

Definition at line 136 of file boxing.cpp.

Here is the call graph for this function:

◆ IsNotNull()

bool IsNotNull ( ) const

Returns the result of a call to built-in boxing function FIsNotNull.

Returns
false if this object represents a nulled object, true otherwise.

Definition at line 162 of file boxing.cpp.

Here is the call graph for this function:

◆ IsNull()

bool IsNull ( ) const
inline

Returns the negated result of a call to built-in boxing function FIsNotNull.

Returns
true if this object represents a nulled object, false otherwise.

Definition at line 1352 of file box.inl.

Here is the call graph for this function:

◆ IsPointer()

bool IsPointer ( ) const
inline

Returns true if this box uses pointer-boxing, otherwise false. The default boxing of pointers will store the pointer to the boxed object in union Placeholder::Pointers.

Returns
true if this box contains an object boxed as pointer type, false otherwise.

Definition at line 737 of file box.inl.

Here is the call graph for this function:

◆ IsSameType()

bool IsSameType ( const Box & other) const
inline

Returns true if other and this object share the same boxed type. Note, if this box has void state (no value boxed), then this method returns false, even if given other is void state as well.

Parameters
otherThe box to compare our type with.
Returns
true if this box has the same type like other, false otherwise.

Definition at line 762 of file box.inl.

◆ IsSignedIntegral()

bool IsSignedIntegral ( ) const
inline

Tests if this box contains a signed integral type (one of the C++ fundamental types of different sizes).

With compilation that disables ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS, this method will be inlined and simply returns IsType<integer>().
Otherwise this method will not be inlined and tests for the five different integer sizes (int8_t, int16_t, int32_t, int64_t and intGap_t).

Returns
true if this box contains a signed integral type, false otherwise.

Definition at line 575 of file box.inl.

Here is the call graph for this function:

◆ IsType()

template<typename TBoxable >
bool IsType ( ) const
inline

Checks if this box stores a value of type TBoxable.

If template parameter TBoxable it is not unboxable, a compile-time assertion is given, with specific guidance why the type must not be unboxed and for that reason must not even be tested for.

Special type void may be given to test if this box does contain a value at all. A box does not contain a value, after

  • default construction,
  • construction with keyword nullptr, or
  • assignment of keyword nullptr.

For more information on the "void state" of boxes, see manual chapter 12.1 Void And Nulled Boxes.

Template Parameters
TBoxableThe boxable type guessed.
Returns
true if this box stores a value that is convertible to type TBoxable, false otherwise.

◆ IsUnsignedIntegral()

bool IsUnsignedIntegral ( ) const
inline

Tests if this box contains an unsigned integral type (one of the C++ fundamental type of different sizes).

With default library compilation that disables ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS, this method will be inlined and simply returns IsType<uinteger>().
Otherwise this method will not be inlined and tests for the five different integer sizes (uint8_t, uint16_t, uint32_t, uint64_t and uintGap_t).

Returns
true if this box contains an unsigned integral type, false otherwise.

Definition at line 593 of file box.inl.

Here is the call graph for this function:

◆ operator bool()

operator bool ( ) const
explicit

Explicit cast operator to bool. Returns the result of built-in box-function FIsTrue.

Returns
true if the boxed value represents value true, false otherwise.

Definition at line 161 of file boxing.cpp.

◆ operator!=()

bool operator!= ( const Box & rhs) const
inline

Comparison operator. Returns the negated result of operator==.

Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object equals rhs, false otherwise.

Definition at line 1281 of file box.inl.

◆ operator<()

bool operator< ( Box const & rhs) const

Comparison operator. Returns the result of invocation of built-in box-function FIsLess.

See also
Sample code provided with documentation of box-function FIsLess.
Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object is smaller than rhs, otherwise false.

Definition at line 172 of file boxing.cpp.

Here is the call graph for this function:

◆ operator<=()

bool operator<= ( Box const & rhs) const

Comparison operator. Uses a combination of operator< and operator==.

Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object is smaller than rhs, otherwise false.

Definition at line 173 of file boxing.cpp.

Here is the call graph for this function:

◆ operator=() [1/2]

Box & operator= ( Box && )
defaultnoexcept

Trivial default move assign operator.

Returns
A reference to this.

◆ operator=() [2/2]

Box & operator= ( const Box & )
defaultnoexcept

Trivial default copy assign operator.

Returns
A reference to this.

◆ operator==()

bool operator== ( Box const & rhs) const

Comparison operator. Returns the result of invocation of built-in boxing function FEquals.

Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object equals rhs, false otherwise.

Definition at line 171 of file boxing.cpp.

Here is the call graph for this function:

◆ operator>()

bool operator> ( Box const & rhs) const

Comparison operator. Uses a combination of operator< and operator==.

Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object is smaller than rhs, otherwise false.

Definition at line 174 of file boxing.cpp.

Here is the call graph for this function:

◆ operator>=()

bool operator>= ( Box const & rhs) const
inline

Comparison operator. Returns the negated result of operator<.

Parameters
rhsThe right hand side argument of the comparison.
Returns
true if this object is smaller than rhs, otherwise false.

Definition at line 1323 of file box.inl.

◆ TypeID()

const std::type_info & TypeID ( ) const
inline

Returns the std::type_info struct describing the boxed type. To get the element type of boxed arrays, use ElementTypeID.

Note
This method is provided for "completeness" and only be used in special situations.
If a box is not initialized (or has nullptr assigned, typeid(void) is returned.
In case of arrays, a std::type_info reference is returned that corresponds to an array of the element type of size 1. For example, if an array of type double of an arbitrary size was boxed, then typeid(double[1])is returned.
Returns
The std::type_info of the mapped type.

Definition at line 941 of file box.inl.

Here is the call graph for this function:

◆ Unbox()

template<typename TUnboxable >
const TUnboxable Unbox ( ) const
inline

Returns the contents of this box converted to type TBoxable. By default this is done by invoking template method Placeholder::Read on field data. This behavior might be customized by specializing structT_Boxer". With debug-builds, the actual type of this object is \ref ALIB_ASSERT_ERROR "asserted" to equal the templated return type. \note With debug-builds, it is \ref ALIB_ASSERT_ERROR "asserted" that given TBoxable is mapped to the type stored, so that IsType returned true for TBoxable. In release compilations, no checks are performed!

Template Parameters
TUnboxableThe type to unbox. If it is not unboxable, a compile-time assertion is given.
Returns
The unboxed value of type TUnboxable .

◆ UnboxArray()

template<typename TElementType >
TElementType * UnboxArray ( ) const
inline

Returns the pointer to the first array element.

Note
With debug-builds, it is asserted that IsArray returns true and the stored type is the same as requested. In release compilations, no checks are performed!
Template Parameters
TElementTypeThe type of array elements
Returns
A pointer to the first array element.

Definition at line 987 of file box.inl.

Here is the call graph for this function:

◆ UnboxCharacter()

wchar UnboxCharacter ( ) const
inline

Unboxes one of the types char, wchar_t, char16_t or char32_t and converts it to wchar.

With default library compilation that disables ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS, this method will be inlined and simply returns Unbox<wchar>().
Otherwise this method will not be inlined and tests for the four different character types before unboxing.

Returns
The stored character.

Definition at line 669 of file box.inl.

Here is the call graph for this function:

◆ UnboxElement()

template<typename TElementType >
TElementType & UnboxElement ( integer idx) const
inline

Returns a reference to element idx of the boxed array.

Note
With debug-builds, it is asserted that IsArray returns true, that the stored type is the same as the requested type and the provided idx is between 0 and the length of the array. In release compilations, no checks are performed!
Template Parameters
TElementTypeThe type of array elements
Parameters
idxThe index of the element to receive.
Returns
The value of the element at idx.

Definition at line 1038 of file box.inl.

Here is the call graph for this function:

◆ UnboxFloatingPoint()

double UnboxFloatingPoint ( ) const

Unboxes a floating point value as double.

Note
If ALIB_FEAT_BOXING_BIJECTIVE_FLOATS is not set, this method will test against double and long double and convert the latter. If it is set, in addition type float is tested.
Returns
true if this box contains a floating point type, false otherwise.

Definition at line 148 of file boxing.cpp.

Here is the call graph for this function:

◆ UnboxLength()

integer UnboxLength ( ) const
inline

Returns the length of a boxed Array. While in theory, the length applies only to arrays, in debug-compilations, no run-time type check is performed. This way, mapped types that use the second "word" of the placeholder to store a value of type integer, may also use this function.
In the latter case, the name of this method might be misleading and therefore, it is recommended to use Data().integer[1] to denote that a custom interpretation of the placeholder is performed. The compilation result is the same.

Some quick rationale for why ALib is generally using signed types for array lengths, is given here.

Returns
The length of the boxed object.

Definition at line 1018 of file box.inl.

Here is the call graph for this function:

◆ UnboxMutable()

template<typename TUnboxable >
TUnboxable UnboxMutable ( ) const
inline

Convenient method to unbox types boxed as pointers, as a non-const pointer type.

See also
Refer to manual chapter 6.5 Constant vs. Mutable Box Contents for more information.
Template Parameters
TUnboxableThe type to unbox. If it is not unboxable, a compile-time assertion is given.
Returns
The unboxed value of type TUnboxable cast to a non-const object.

◆ UnboxSignedIntegral()

integer UnboxSignedIntegral ( ) const
inline

Unboxes a signed integral.

With default library compilation that disables ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS, this method will be inlined and simply returns Unbox<integer>().
Otherwise this method will not be inlined and tests for the five different integer sizes (1, 2, 4 and 8 bytes size and the alib::intGap_t) before unboxing.

Returns
The boxed signed integral value.

Definition at line 610 of file box.inl.

Here is the call graph for this function:

◆ UnboxUnsignedIntegral()

uinteger UnboxUnsignedIntegral ( ) const
inline

Unboxes an unsigned integral.

With default library compilation that disables ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS, this method will be inlined and simply returns Unbox<uinteger>().
Otherwise this method will not be inlined and tests for the five different integer sizes (1, 2, 4 and 8 bytes size and the alib::uintGap_t) before unboxing.

Returns
The boxed unsigned integral value.

Definition at line 627 of file box.inl.

Here is the call graph for this function:

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