ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
box.cpp
1#if ALIB_STRINGS
6#endif
7
8namespace alib {
9
10//==================================================================================================
11/// This is the reference documentation of sub-namespace \b boxing of the \aliblink, which
12/// holds types of library module \alib_boxing.
13///
14/// Extensive documentation for this module is provided with
15/// #"alib_mod_boxing;ALib Module Boxing - Programmer's Manual".
16//==================================================================================================
17namespace boxing {
18
19//##################################################################################################
20//##################################################################################################
21// class Box
22//##################################################################################################
23//##################################################################################################
24
25#if ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
26 bool Box::IsSignedIntegral() const
27 {
28 #if ALIB_SIZEOF_INTEGER == 8
29 return IsType< int64_t >()
31 #else
32 return IsType< int32_t >()
34 #endif
38 }
39
40 bool Box::IsUnsignedIntegral() const
41 {
42 #if ALIB_SIZEOF_INTEGER == 8
43 return IsType<uint64_t >()
45 #else
46 return IsType<uint32_t >()
48 #endif
52 }
53
55 {
56 #if ALIB_SIZEOF_INTEGER == 8
57 return IsType< int64_t >() ? ( Unbox< int64_t >() )
59 #else
60 return IsType< int32_t >() ? ( Unbox< int32_t >() )
62 #endif
66 }
67
68
70 {
71 #if ALIB_SIZEOF_INTEGER == 8
72 return IsType<uint64_t >() ? ( Unbox<uint64_t >() )
74 #else
75 return IsType<uint32_t >() ? ( Unbox<uint32_t >() )
77 #endif
81 }
82#endif
83
84#if ALIB_FEAT_BOXING_BIJECTIVE_CHARACTERS
85bool Box::IsCharacter() const
86{
87 return IsType<char >()
92}
93
95{
96 return IsType<char >() ? wchar( Unbox<char >() )
100 : wchar( Unbox<char32_t>() );
101}
102#endif
103
105 return IsType< double>()
106 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
107 || IsType< float >()
108 #endif
109 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
111 #endif
112 ;
113}
114
116 #if ALIB_FEAT_BOXING_BIJECTIVE_FLOATS
117 if( IsType< float >() ) return double( Unbox<float >() );
118 #endif
119
120 #if ALIB_SIZEOF_LONGDOUBLE_REPORTED <= 2 * ALIB_SIZEOF_INTEGER
121 if( IsType<long double>() ) return double( Unbox<long double>() );
122 #endif
123
124 return Unbox<double>();
125}
126
127#if !DOXYGEN
128 Box::operator bool() const { return Call<FIsTrue >(); }
129bool Box::IsNotNull () const { return Call<FIsNotNull >(); }
130size_t Box::Hashcode () const { return Call<FHashcode >(); }
132void Box::Clone( MonoAllocator& memory) { Call<FClone >( memory ); } )
133#endif
134
135//##################################################################################################
136// Non-anonymous functions
137//##################################################################################################
138bool FIsNotNull::ConstantTrue( const alib::Box & ) { return false; }
139
140}} // namespace [alib::boxing]
141
142using namespace alib::boxing;
143bool Box::operator==(const Box& rhs) const { return Call<FEquals>(rhs); }
144bool Box::operator< (const Box& rhs) const { return Call<FIsLess>(rhs); }
145bool Box::operator<=(const Box& rhs) const { return Call<FIsLess>(rhs) || Call<FEquals>(rhs); }
146bool Box::operator> (const Box& rhs) const { return !Call<FIsLess>(rhs) && !Call<FEquals>(rhs); }
#define IF_ALIB_MONOMEM(...)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
void Clone(MonoAllocator &memory)
bool operator>(Box const &rhs) const
Definition box.cpp:146
uinteger UnboxUnsignedIntegral() const
Definition box.hpp:481
bool IsUnsignedIntegral() const
Definition box.hpp:457
double UnboxFloatingPoint() const
Definition box.cpp:115
integer UnboxSignedIntegral() const
Definition box.hpp:469
size_t Hashcode() const
bool IsNotNull() const
bool IsFloatingPoint() const
Definition box.cpp:104
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call(TArgs &&... args) const
Definition box.hpp:964
bool IsType() const
bool operator<(Box const &rhs) const
Definition box.cpp:144
bool IsCharacter() const
Definition box.hpp:501
bool operator==(Box const &rhs) const
Definition box.cpp:143
bool IsSignedIntegral() const
Definition box.hpp:444
bool operator<=(Box const &rhs) const
Definition box.cpp:145
wchar UnboxCharacter() const
Definition box.hpp:513
Box() noexcept
Definition box.hpp:222
DOXYGEN.
Definition box.cpp:17
Definition alox.cpp:14
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
characters::wchar wchar
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
boxing::Box Box
Type alias in namespace #"%alib".
Definition box.hpp:1128
lang::uinteger uinteger
Type alias in namespace #"%alib".
Definition integers.hpp:152
static bool ConstantTrue(const Box &)
Definition box.cpp:138