ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Static Fields | List of all members
T_SizeInPlaceholder< TMappedPlain > Struct Template Reference

Class Description

template<typename TMappedPlain>
struct aworx::lib::boxing::T_SizeInPlaceholder< TMappedPlain >


This specializable TMP struct must be set for custom types, if the following applies:

Background:
The default implementations of FHashcode and FEquals must use the first N "relevant" bytes of the placeholder only. The non-relevant bytes are not written and therefore must not be taken into account.
To receive the number of relevant bytes, they invoke Box::GetPlaceholderUsageLength (at run-time). This value is set at compile-time with the creation of a mapped type's vtable. While for array types, the value is set to the overall size of union Placeholder, for non-array types, the value of this TMP struct is used.

It might be surprising, but a built-in specialization exists for even a C++ fundamental type long double, which is dependent on the compiler/platform. For example, on GNU/Linux 64-bit, GCC reports 16 with sizeof(long double). However, if a long double value is copied, e.g with:

 *pointerToLongDouble= 3.14L;

then only 10 bytes are written. The reason for this is that sizeof reports the size needed for alignment when placed in an array of that type. In the case of ALib Boxing, 6 bytes of the placeholder remain random and therefore must not be used for hashing or testing values on equality.

Template Parameters
TMappedPlainThe mapped type to modify relevant placeholder length for FHashcode and FEquals implementation.

Definition at line 367 of file typetraits.inl.

Public Static Fields

static constexpr unsigned int value = sizeof(TMappedPlain)
 

Member Data Documentation

◆ value

constexpr unsigned int value = sizeof(TMappedPlain)
staticconstexpr

The size used with the placeholder

Definition at line 370 of file typetraits.inl.


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