18# if ALIB_ENUMS && ALIB_STRINGS
59#if ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
62 #if ALIB_SIZEOF_INTEGER == 8
76 #if ALIB_SIZEOF_INTEGER == 8
90 #if ALIB_SIZEOF_INTEGER == 8
105 #if ALIB_SIZEOF_INTEGER == 8
109 return
IsType<uint32_t >() ? (
Unbox<uint32_t >() )
118#if ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
139 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
142 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
150 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
154 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
161 Box::operator bool()
const {
return Call<FIsTrue >(); }
175namespace alib {
namespace boxing {
198bool FIsNotNull_Default(
const Box& box )
209std::size_t FHashcode_Default(
const Box& self )
213 return size_t(0xa814e72cUL)
214 + size_t( self.
TypeID().hash_code() )
220 return size_t(0x49a024efUL)
221 + size_t( self.
TypeID().hash_code() )
227 std::size_t result= 0xa925eb91L
233 if( size == 2 || size == 6 )
239 for(
integer i= 0 ; i < length ; ++i )
240 result = 67 * result + array[i];
242 return size_t( result );
248 for(
integer i= 0 ; i < length ; ++i )
249 result = 67*result + array[i];
251 return size_t( result );
257 for(
integer i= 0 ; i < length ; ++i )
258 result = std::size_t( 67 * result + array[i] );
260 return std::size_t( result );
266 unsigned char* array= self.
Data().
Pointer<
unsigned char>();
267 for(
int i= 0 ; i < length ; ++i )
268 result = 67*result + array[i];
270 return size_t( result );
275 size_t result= size_t(0xcf670957UL)
276 + size_t( self.
TypeID().hash_code() );
285 & ((Bit1 << (usedLen * 8) )- 1) ) * 32194735 )
298 & ((Bit1 << ((usedLen -
sizeof(
uinteger)) * 8) )- 1) ) * 321947 )
310bool FEquals_Default(
const Box& self,
const Box& rhs )
340 uinteger mask= (Bit1 << (usedLen * 8) )- 1;
342 == ( rhs .
Data().GetUInteger(0) & mask );
357 == ( rhs .
Data().GetUInteger(1) & mask );
364bool FEquals_double(
const Box& self,
const Box& rhsBox )
374 #if defined(__clang__)
375 #pragma clang diagnostic push
376 #pragma clang diagnostic ignored "-Wfloat-equal"
382 || std::fabs( lhs - rhs ) <=
static_cast<double>( 2.0f * std::numeric_limits<float>::epsilon() );
384 #if defined(__clang__)
385 #pragma clang diagnostic pop
389bool FEquals_integer(
const Box& self,
const Box& rhsBox )
392 return FEquals_double( rhsBox, self );
402bool FEquals_uinteger(
const Box& self,
const Box& rhsBox )
405 return FEquals_double( rhsBox, self );
415bool FEquals_char(
const Box& self,
const Box& rhs )
423template<
typename TChar>
424bool FEquals_TChar_Arr(
const Box& lhs,
const Box& rhs )
431 if ( (boxBuf ==
nullptr) != (compBuf ==
nullptr) )
436 if ( boxLen != compLen )
445bool FIsLess_Default(
const Box& box,
const Box& comp )
447 return std::type_index( box.
TypeID() ) < std::type_index(comp.
TypeID() )
453#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
454bool FIsLess_integer(
const Box& self,
const Box& rhs )
461 return std::type_index( self.
TypeID() ) < std::type_index( rhs.
TypeID() );
464bool FIsLess_uinteger(
const Box& self,
const Box& rhs )
471 return std::type_index( self.
TypeID() ) < std::type_index( rhs.
TypeID() );
476bool helperBijectiveLessS(
integer selfVal,
const Box& selfType,
const Box& rhs )
483 return std::type_index( selfType.
TypeID() ) < std::type_index( rhs.
TypeID() );
486bool helperBijectiveLessU(
uinteger selfVal,
const Box& selfType,
const Box& rhs )
493 return std::type_index( selfType.
TypeID() ) < std::type_index( rhs.
TypeID() );
496bool FIsLess_int8_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
static_cast< integer>( self.
Unbox< int8_t >() ), self, rhs ); }
497bool FIsLess_int16_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
static_cast< integer>( self.
Unbox< int16_t >() ), self, rhs ); }
498bool FIsLess_int32_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
static_cast< integer>( self.
Unbox< int32_t >() ), self, rhs ); }
499bool FIsLess_int64_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
static_cast< integer>( self.
Unbox< int64_t >() ), self, rhs ); }
500bool FIsLess_intGap_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessS(
static_cast< integer>( self.
Unbox<
intGap_t>() ), self, rhs ); }
502bool FIsLess_uint8_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
static_cast<uinteger>( self.
Unbox<uint8_t >() ), self, rhs ); }
503bool FIsLess_uint16_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
static_cast<uinteger>( self.
Unbox<uint16_t >() ), self, rhs ); }
504bool FIsLess_uint32_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
static_cast<uinteger>( self.
Unbox<uint32_t >() ), self, rhs ); }
505bool FIsLess_uint64_t (
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
static_cast<uinteger>( self.
Unbox<uint64_t >() ), self, rhs ); }
506bool FIsLess_uintGap_t(
const Box& self,
const Box& rhs ) {
return helperBijectiveLessU(
static_cast<uinteger>( self.
Unbox<
uintGap_t>() ), self, rhs ); }
510bool FIsLess_char(
const Box& self,
const Box& rhs )
515 return std::type_index( self.
TypeID() ) < std::type_index( rhs.
TypeID() );
520bool FIsLess_double(
const Box& self,
const Box& rhs )
522 double lhs= self.
Unbox<
double>();
527 return std::type_index( self.
TypeID() ) < std::type_index( rhs.
TypeID() );
530#if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
531 bool FIsLess_float(
const Box& self,
const Box& rhs )
533 float lhs= self.
Unbox<
float>();
534 if( rhs.
IsType<
float >() )
return lhs < rhs.
Unbox<
float >() ;
535 if( rhs.
IsType<
double >() )
return lhs < static_cast<float> ( rhs.
Unbox<
double>() );
539 return std::type_index( self.
TypeID() ) < std::type_index( rhs.
TypeID() );
556 auto* src= placeHolder.
Pointer<
char>();
557 if( src==
nullptr || placeHolder.
GetInteger(1) < 0 )
561 if( alignment >
sizeof(std::ptrdiff_t) )
562 alignment=
sizeof(std::ptrdiff_t);
575bool FIsTrue_Default(
const Box& self )
587 & ((Bit1 << (usedLen * 8) )- 1) ) != 0;
600 & ((Bit1 << (usedLen -
sizeof(
uinteger)) * 8 )- 1) ) != 0;
612template<
typename TChar>
613bool FIsLess_TChar_arr(
const Box& lhs,
const Box& rhs )
618 return std::type_index( lhs.
TypeID() ) < std::type_index(rhs.
TypeID() );
622template<
typename TChar,
typename TAllocator>
651template<
typename TCharSrc,
typename TChar,
typename TAllocator>
682#if ALIB_DEBUG && !DOXYGEN
683namespace{
unsigned int initFlag= 0; }
686#if ALIB_DEBUG && !DOXYGEN
690 extern long double dbgLongDoubleWriteTestMem[2];
691 extern void dbgLongDoubleTrueLengthSet();
692 extern bool dbgLongDoubleTrueLengthTest();
703 ALIB_ASSERT_ERROR( initFlag == 0x92A3EF61,
"BOXING",
"Not initialized when calling shutdown." )
710 ALIB_ASSERT_ERROR( initFlag == 0,
"BOXING",
"This method must not be invoked twice." )
717 dbgLongDoubleTrueLengthSet();
718 dbgLongDoubleWriteTestMem[0]= 0.0L;
720 "Platform not supported. Template specialization T_SizeInPlaceholder<long double> contains wrong size" )
730DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_1])
732DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_1])
734 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
746 #if ALIB_SIZEOF_INTEGER == 8
754 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
757 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
762 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
771DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_2])
773DOX_MARKER([DOX_BOXING_OPTIMIZE_REGISTER_2])
828 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
844 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
854 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
861 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
877 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
887 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
898 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
914 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
921 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
935 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
951 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
957 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
984 #if !ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
996 #if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
1026 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
1030 if constexpr (
sizeof(
long double) <=
sizeof(
Placeholder) )
1087 #if ALIB_EXT_LIB_THREADS_AVAILABLE
1101#if ALIB_DEBUG_BOXING
1109 assert( initFlag == 0x92A3EF61 );
1114 if( vtable==
nullptr)
1117 if( increaseUsageCounter )
1128 ALIB_ERROR(
"BOXING",
"Static VTable of mapped type <", typeNameNarrow,
1129 "> not registered. Use Macro ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER with bootstrapping." )
1136 ALIB_ERROR(
"BOXING",
"Static VTable of mapped type <", typeNameNarrow,
1137 "[]> not registered. Use Macro ALIB_BOXING_REGISTER_MAPPED_ARRAY_TYPE with bootstrapping." )
uinteger UnboxUnsignedIntegral() const
ALIB_API bool operator<(Box const &rhs) const
size_t ArrayElementSize() const
TElementType * UnboxArray() const
ALIB_API bool IsNotNull() const
wchar UnboxCharacter() const
integer UnboxLength() const
bool IsFloatingPoint() const
bool IsSameType(const Box &other) const
bool IsUnsignedIntegral() const
ALIB_API size_t Hashcode() const
bool IsSignedIntegral() const
unsigned int GetPlaceholderUsageLength() const
ALIB_API bool operator<=(Box const &rhs) const
ALIB_API double UnboxFloatingPoint() const
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call(TArgs &&... args) const
const std::type_info & TypeID() const
const std::type_info & ElementTypeID() const
const Placeholder & Data() const
integer UnboxSignedIntegral() const
ALIB_API bool operator>(Box const &rhs) const
ALIB_API bool operator==(Box const &rhs) const
ALIB_API void Clone(MonoAllocator &memory)
const TUnboxable Unbox() const
ALIB_API NAString & GetShort(NAString &target)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_WARNINGS_RESTORE
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define IF_ALIB_MONOMEM(...)
#define ALIB_REL_DBG(releaseCode,...)
void bootStrapCFM()
Bootstrap helper method.
ALIB_API void DbgCheckRegistration(detail::VTable *vtable, bool increaseUsageCounter)
ALIB_API void DbgCheckIsInitialized()
void BootstrapRegister(typename TFDecl::Signature function)
void BootstrapRegisterDefault(typename TFDecl::Signature function)
int Compare(const TChar *lhs, const TChar *rhs, integer cmpLength)
Recursive
Denotes whether recursion is performed/allowed or not.
Inclusion
Denotes how members of a set something should be taken into account.
ValueReference
Denotes if a value is interpreted as an absolute or relative number.
Whitespaces
Denotes whether a string is trimmed or not.
CreateDefaults
Denotes whether default entities should be created or not.
Caching
Denotes if a cache mechanism is enabled or disabled.
Side
Denotes if something is left or right.
Propagation
Denotes whether a e.g a setting should be propagated.
Switch
Denotes if sth. is switched on or off.
Initialization
Used for example with constructors that allow to suppress initialization of members.
Safeness
Denotes whether something should be performed in a safe or unsafe fashion.
SortOrder
Denotes sort order.
Reach
Denotes the reach of something.
SourceData
Denotes if the source data should be moved or copied.
Timezone
Denotes whether a time value represents local time or UTC.
Case
Denotes upper and lower case character treatment.
Alignment
Denotes Alignments.
Timing
Denotes if asynchronous tasks become synchronized.
CreateIfNotExists
Denotes whether something should be created if it does not exist.
Phase
Denotes a phase, e.g.,of a transaction.
ContainerOp
Denotes standard container operations.
lang::uinteger uinteger
Type alias in namespace alib.
characters::wchar wchar
Type alias in namespace alib.
characters::xchar xchar
Type alias in namespace alib.
lang::intGap_t intGap_t
Type alias in namespace alib.
lang::uintGap_t uintGap_t
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
static bool ComparableTypes(const Box &self, const Box &rhs)
static size_t UsePlaceholderBytes(const Box &self)
static ALIB_API bool ConstantTrue(const Box &)
static ALIB_API void Shutdown()
Needs to be called only in debug versions to shut down internal hashtables cleanly.
DbgFactoryType DbgProduction
Debug information.
const std::type_info & Type
@ Unregistered
Not registered, yet.
const std::type_info & ElementType
constexpr TReturn * Pointer() const
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE constexpr integer GetInteger(int idx) const
detail::UnionIntegrals Integrals
Collection of integrals of different sizes.
constexpr uinteger GetUInteger(int idx) const
detail::UnionPointers Pointers
Collection of void, char and character pointers.
constexpr void * VoidPointer() const
integer Int
Signed integral of platform-dependent size.
uinteger UInt
Unsigned integral of platform-dependent size.
const void * CVoid
A constant void pointer.