This function compares two boxes.
A default implementation is registered that compares the types (IsSameType) and if equal, with arrays compares the array's length, nulled state and finally the contents using memcmp.
For non-array types, it compares the relevant bytes in the placeholder. The number of leading relevant bytes is available with method GetPlaceholderUsageLength.
Type-specific implementations are given and registered for fundamental types. Integrals of different sizes and floating point values will be compared by using UnboxSignedIntegral, UnboxUnsignedIntegral and UnboxFloatingPoint and appropriate casting. In the case of floating point comparison, an epsilon distance is duly taken into account.
For custom types, with ComparableTypes, a templated implementation is suggested: Rather than implementing a specific box-function, the custom type should implement operator== and register an instantiation of the templated function.
Definition at line 112 of file functiondecls.inl.
Public Type Index: | |
| using | Signature = bool (*) ( const Box& self, const Box& rhs) |
Public Static Method Index: | |
| template<typename TComparable> | |
| static bool | ComparableTypes (const Box &self, const Box &rhs) |
| using alib::boxing::FEquals::Signature = bool (*) ( const Box& self, const Box& rhs) |
Signature of the invokable function.
| self | The box that the function was invoked on. |
| rhs | The box to compare. |
Definition at line 119 of file functiondecls.inl.
|
static |
Templated implementation of the function signature, usable with boxable types which have operator== implemented.
requires.false is returned, if both are nulled, true.| TComparable | The mapped type that can be compared using operator==. |
| self | The box that the function was invoked on. |
| rhs | The boxed value to compare. |
true if self equals rhs, false otherwise.