This specializable TMP struct must be set for custom types, if the following applies:
sizeof()
operator reports on the mapped type's size.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.
TMappedPlain | The mapped type to modify relevant placeholder length for FHashcode and FEquals implementation. |
Definition at line 367 of file typetraits.inl.
Public Static Field Index: | |
static constexpr unsigned int | value = sizeof(TMappedPlain) |
|
staticconstexpr |
The size used with the placeholder
Definition at line 370 of file typetraits.inl.