ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lang Namespace Reference

Description:

This namespace holds types and functions of the module ALib Lang, which are very close to the C++ language itself. The entities found here are always included in any ALib Build and are accessed by including the header ALib.Lang.H.

Reference Documentation

Type Index:

struct  Allocator
 
struct  AllocatorInterface
 
struct  AllocatorMember
 
struct  AllocatorMember< HeapAllocator >
 
struct  BidiListHook
 
struct  BidiNodeBase
 
struct  CallerInfo
 
struct  DbgAlloc
 
struct  DbgCriticalSections
 
class  DbgTypeDemangler
 
struct  HeapAllocator
 
class  Owner
 
class  OwnerRecursive
 
class  OwnerShared
 
class  OwnerSharedTimed
 
class  OwnerTimed
 
class  OwnerTry
 
class  OwnerTryShared
 
struct  Placeholder
 
class  Plugin
 
class  PluginContainer
 
struct  RTTRAllocator
 
struct  SidiListHook
 
struct  SidiNodeBase
 
struct  StdContainerAllocator
 
struct  StdContainerAllocatorRecycling
 
class  TBitSet
 
struct  TypeFunctors
 
struct  UnknownTag
 

Concepts

concept  IsAllocator
 
concept  IsNullptr
 

Type Definition Index:

using integer = platform_specific
 
using intGap_t = platform_specific
 
using ShiftOpRHS = int
 
using uinteger = platform_specific
 
using uintGap_t = platform_specific
 

Enumeration Index:

enum class  Alignment { Left , Right , Center }
 Denotes Alignments. More...
 
enum class  Bool : bool { False , True }
 
enum class  Caching { Disabled , Enabled , Auto }
 Denotes if a cache mechanism is enabled or disabled. More...
 
enum class  Case : bool { Sensitive , Ignore }
 Denotes upper and lower case character treatment. More...
 
enum class  ContainerOp {
  Insert , Remove , Get , GetCreate ,
  Create
}
 Denotes standard container operations. More...
 
enum class  CreateDefaults : bool { No , Yes }
 Denotes whether default entities should be created or not. More...
 
enum class  CreateIfNotExists : bool { No , Yes }
 Denotes whether something should be created if it does not exist. More...
 
enum class  CurrentData : bool { Keep , Clear }
 
enum class  Inclusion : bool { Include , Exclude }
 Denotes how members of a set something should be taken into account. More...
 
enum class  Initialization { Suppress , Default , Nulled }
 Used for example with constructors that allow to suppress initialization of members. More...
 
enum class  Phase { Begin = (1 << 0) , End = (1 << 1) }
 Denotes a phase, e.g.,of a transaction. More...
 
enum class  Propagation : bool { Omit , ToDescendants }
 Denotes whether a e.g a setting should be propagated. More...
 
enum class  Reach : bool { Global , Local }
 Denotes the reach of something. More...
 
enum class  Recursive : bool { No , Yes }
 Denotes whether recursion is performed/allowed or not. More...
 
enum class  Responsibility : bool { KeepWithSender , Transfer }
 
enum class  Safeness : bool { Safe , Unsafe }
 Denotes whether something should be performed in a safe or unsafe fashion. More...
 
enum class  Side : bool { Left , Right }
 Denotes if something is left or right. More...
 
enum class  SortOrder : bool { Ascending , Descending }
 Denotes sort order. More...
 
enum class  SourceData : bool { Copy , Move }
 Denotes if the source data should be moved or copied. More...
 
enum class  Switch : bool { Off , On }
 Denotes if sth. is switched on or off. More...
 
enum class  Timezone : bool { Local , UTC }
 Denotes whether a time value represents local time or UTC. More...
 
enum class  Timing { Async , Sync }
 Denotes if asynchronous tasks become synchronized. More...
 
enum class  ValueReference { Absolute , Relative }
 Denotes if a value is interpreted as an absolute or relative number. More...
 
enum class  Whitespaces : bool { Trim , Keep }
 Denotes whether a string is trimmed or not. More...
 

Function Index:

template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int BitCount (TIntegral value)
 
template<typename T>
constexpr int bitsofval (const T &val)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int CLZ (TIntegral value)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int CLZ0 (TIntegral value)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int CTZ (TIntegral value)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int CTZ0 (TIntegral value)
 
template<typename T>
void Destruct (T &object)
 
template<typename T>
requires std::default_initializable<T>
constexpr bool IsNotNull (const T &t)
 
template<typename T>
requires std::default_initializable<T>
constexpr bool IsNull (const T &t)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int Log2OfSize ()
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr TIntegral LowerBits (ShiftOpRHS width, TIntegral value)
 
template<ShiftOpRHS TWidth, typename TIntegral>
requires std::integral<TIntegral>
constexpr TIntegral LowerBits (TIntegral value)
 
template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth < bitsof(TIntegral) )
constexpr TIntegral LowerMask ()
 
template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth >= bitsof(TIntegral) )
constexpr TIntegral LowerMask ()
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr TIntegral LowerMask (ShiftOpRHS width)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int MSB (TIntegral value)
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr int MSB0 (TIntegral value)
 
template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator& (const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
 
template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator^ (const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
 
template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator| (const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
 
template<typename TTo, typename TFrom>
ALIB_WARNINGS_RESTORE TTo * SafeCast (TFrom *derived)
 
template<typename T>
requires std::default_initializable<T>
constexpr void SetNull (T &t)
 
template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth < bitsof(TIntegral) )
constexpr TIntegral UpperMask ()
 
template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth >= bitsof(TIntegral) )
constexpr TIntegral UpperMask ()
 
template<typename TIntegral>
requires std::integral<TIntegral>
constexpr TIntegral UpperMask (ShiftOpRHS width)
 

Variable Index:

unsigned int DBG_CRITICAL_SECTION_YIELD_OR_SLEEP_TIME_IN_NS
 

Type Definition Details:

◆ integer

using alib::lang::integer = platform_specific

This type specifies platform-independent integral values of the 'natural' bit-size of the underlying platform. In general, on 32-bit systems this will be 32-bit wide, on 64-bit systems, 64-bits. Hence, on standard architectures, it has the same bit-size and signedness as std::ptrdiff_t.

The type can be considered as a signed version of std::size_t. It is needed because standard type 'int' is not specified in respect to its size. E.g., GNU C++ and Clang compiler use 32-Bit integers for type int, even on 64-Bit platforms.

See also alib::uinteger.

Note
This documentation is generated using the 64-Bit version of the library. In fact, the definition as int64_t shown here, is not guaranteed platform-specific.

Definition at line 32 of file integers.inl.

◆ intGap_t

using alib::lang::intGap_t = platform_specific

This type, together with its counterpart alib::uintGap_t is used to fill a gap that occurs when method overloads or template specialization are needed for integer types. The rationale behind and use of this pair of types is best explained with a sample.

Consider the following code:

// Template function
template <typename TInteger> const char* MyFunc(TInteger val) { return "NOT IMPLEMENTED"; }
// Specializations for integer types
template<> const char* MyFunc( int8_t ) { return "Type= int8_t "; }
template<> const char* MyFunc( uint8_t ) { return "Type= uint8_t "; }
template<> const char* MyFunc( int16_t ) { return "Type= int16_t"; }
template<> const char* MyFunc( uint16_t ) { return "Type= uint16_t"; }
template<> const char* MyFunc( int32_t ) { return "Type= int32_t"; }
template<> const char* MyFunc( uint32_t ) { return "Type= uint32_t"; }
template<> const char* MyFunc( int64_t ) { return "Type= int64_t"; }
template<> const char* MyFunc( uint64_t ) { return "Type= uint64_t"; }
// TestMethod
void test()
{
// test std int types
cout << " int8_t : " << MyFunc( ( int8_t ) 0 ) << endl; // OK
cout << "uint8_t : " << MyFunc( (uint8_t ) 0 ) << endl; // OK
cout << " int16_t : " << MyFunc( ( int16_t) 0 ) << endl; // OK
cout << "uint16_t : " << MyFunc( (uint16_t) 0 ) << endl; // OK
cout << " int32_t : " << MyFunc( ( int32_t) 0 ) << endl; // OK
cout << "uint32_t : " << MyFunc( (uint32_t) 0 ) << endl; // OK
cout << " int64_t : " << MyFunc( ( int64_t) 0 ) << endl; // OK
cout << "uint64_t : " << MyFunc( (uint64_t) 0 ) << endl; // OK
cout << endl;
// test 'language' types
cout << " long : " << MyFunc( ( long ) 0 ) << endl; // Gap on common 32-bit platforms and 64-bit MSVC
cout << "unsigned long : " << MyFunc( (unsigned long ) 0 ) << endl; // Gap on common 32-bit platforms and 64-bit MSVC
cout << endl;
cout << " long long: " << MyFunc( ( long long) 0 ) << endl; // Gap on 64-Bit GNU C++
cout << "unsigned long long: " << MyFunc( (unsigned long long) 0 ) << endl; // Gap on 64-Bit GNU C++
cout << endl;
// further info
cout << endl;
cout << "sizeof( long )= " << sizeof( long ) << endl;
cout << "sizeof(unsigned long )= " << sizeof(unsigned long ) << endl;
cout << endl;
cout << "sizeof( long long)= " << sizeof( long long) << endl;
cout << "sizeof(unsigned long long)= " << sizeof(unsigned long long) << endl;
}

When this is run under 64 Bit - Linux, GNU compiler, the following output is produced:

 int8_t           : Type=  int8_t 
uint8_t           : Type= uint8_t 
 int16_t          : Type=  int16_t
uint16_t          : Type= uint16_t
 int32_t          : Type=  int32_t
uint32_t          : Type= uint32_t
 int64_t          : Type=  int64_t
uint64_t          : Type= uint64_t

         long     : Type=  int64_t
unsigned long     : Type= uint64_t

         long long: NOT IMPLEMENTED
unsigned long long: NOT IMPLEMENTED


sizeof(         long     )= 8
sizeof(unsigned long     )= 8

sizeof(         long long)= 8
sizeof(unsigned long long)= 8

This is not what many C++ programmers would expect: Although type long long is the same 64-bit type as long, the template method is not seen as specialized by the compiler. Therefore, we have a "gap" in the definition of specializations for types long long and unsigned long long.

When compiling and running the same sample code under GNU compiler 32-bit or under MSVC (Microsoft compiler), 32 or 64-bit, then the gap "moves" to be with types long and unsigned long instead. Here, this hurts a lot, because code that uses a simple integer constant 1L is not fetched by the template specializations!

The lesson learned is that two more specializations are needed and that their types are dependent on the compiler and library used. Because it is not allowed to specialize simply with all possible extra variants (this would lead to doubly defined methods), a preprocessor switch that chooses the right types to fill the gap is needed.

This type, together with uintGap_t, does exactly this: using the preprocessor to select the right "missing" type.

To fix the sample above, the following two specializations of the template method need to be added:

template<> const char* MyFunc( alib:: intGap_t ) { return "Type= intGap_t"; }
template<> const char* MyFunc( alib::uintGap_t ) { return "Type= uintGap_t"; }

When overloading functions with integer types, similar rules apply: To have the complete set of integer types covered, 10 overloads are needed: from type int8_t to type int64_t, type intGap_t and then those five types in two versions, signed and unsigned. Only with all overloads in place, compiler warnings (on high warning levels), compiler errors due to ambiguouties and/or the necessity of explicit type conversions are avoided.

See also
Along with these definitions, preprocessor symbol ALIB_SIZEOF_INTGAP is defined.

Definition at line 85 of file integers.inl.

◆ ShiftOpRHS

The C++ language defines the right-hand-side argument of bit shift operations to be of type int. To increase code readability we define this type explicitly.

Definition at line 20 of file bits.inl.

◆ uinteger

using alib::lang::uinteger = platform_specific

Unsigned version of alib::integer. This type should be the same as std::size_t on all platforms.

Definition at line 36 of file integers.inl.

◆ uintGap_t

using alib::lang::uintGap_t = platform_specific

Used to complete overwriting methods and template specializations.
See signed sibling type alib::intGap_t for more information.

Definition at line 89 of file integers.inl.

Enumeration Details:

◆ Alignment

enum class alib::lang::Alignment
strong

Denotes Alignments.

Enumerator
Left 

Chooses left alignment.

Right 

Chooses right alignment.

Center 

Chooses centered alignment.

Definition at line 15 of file commonenumdefs.inl.

◆ Bool

enum class alib::lang::Bool : bool
strong

Enumeration representing a boolean value. While the use of this enumeration type seems senseless at the first sight (as the C++ has keywords bool, false and true), the reason for its existence is to have write and parse methods in place using the concept of ALib Enum Records.

The default name translation table is equipped with various 'overloaded' element entries like "yes", "no", "on", "off", "1" or "0". Furthermore, if other languages should be supported, this can even be extended at run-time.

Enumerator
False 

False value.

True 

True value.

Definition at line 32 of file commonenumdefs.inl.

◆ Caching

enum class alib::lang::Caching
strong

Denotes if a cache mechanism is enabled or disabled.

Enumerator
Disabled 

Caching is disabled.

Enabled 

Caching is enabled.

Auto 

Auto/default mode.

Definition at line 41 of file commonenumdefs.inl.

◆ Case

enum class alib::lang::Case : bool
strong

Denotes upper and lower case character treatment.

Enumerator
Sensitive 

Chooses an operation mode which differs between lower and upper case letters (usually the default).

Ignore 

Chooses an operation mode which does not differ between between lower and upper case letters.

Definition at line 52 of file commonenumdefs.inl.

◆ ContainerOp

enum class alib::lang::ContainerOp
strong

Denotes standard container operations.

Enumerator
Insert 

Denotes insertions.

Remove 

Denotes removals.

Get 

Denotes to search data.

GetCreate 

Denotes to create data if not found.

Create 

Denotes to create data.

Definition at line 64 of file commonenumdefs.inl.

◆ CreateDefaults

enum class alib::lang::CreateDefaults : bool
strong

Denotes whether default entities should be created or not.

Enumerator
No 

Do not create.

Yes 

Create default values.

Definition at line 76 of file commonenumdefs.inl.

◆ CreateIfNotExists

enum class alib::lang::CreateIfNotExists : bool
strong

Denotes whether something should be created if it does not exist.

Enumerator
No 

Do not create.

Yes 

Create if something does not exist.

Definition at line 85 of file commonenumdefs.inl.

◆ CurrentData

enum class alib::lang::CurrentData : bool
strong

Denotes if current, existing data should be cleared or if new data should be appended or otherwise added.

Enumerator
Keep 

Chooses not no clear existing data.

Clear 

Chooses to clear existing data.

Definition at line 95 of file commonenumdefs.inl.

◆ Inclusion

enum class alib::lang::Inclusion : bool
strong

Denotes how members of a set something should be taken into account.

Enumerator
Include 

Chooses inclusion.

Exclude 

Chooses exclusion.

Definition at line 104 of file commonenumdefs.inl.

◆ Initialization

enum class alib::lang::Initialization
strong

Used for example with constructors that allow to suppress initialization of members.

Enumerator
Suppress 

Suppress initialization. Writes "Suppress", reads in addition "None".

Default 

Perform default initialization. Writes "Default", reads in addition "Initialize".

Nulled 

Perform initialization with a nulled value. Writes "Nulled", reads in addition "Zero".

Definition at line 113 of file commonenumdefs.inl.

◆ Phase

enum class alib::lang::Phase
strong

Denotes a phase, e.g.,of a transaction.

Enumerator
Begin 

The start of a transaction.

End 

The end of a transaction.

Definition at line 126 of file commonenumdefs.inl.

◆ Propagation

enum class alib::lang::Propagation : bool
strong

Denotes whether a e.g a setting should be propagated.

Enumerator
Omit 

Do not propagate changes.

ToDescendants 

Propagate changes to descendants/children/subcomponents.

Definition at line 135 of file commonenumdefs.inl.

◆ Reach

enum class alib::lang::Reach : bool
strong

Denotes the reach of something.

Enumerator
Global 

Denotes global reach.

Local 

Denotes local reach.

Definition at line 144 of file commonenumdefs.inl.

◆ Recursive

enum class alib::lang::Recursive : bool
strong

Denotes whether recursion is performed/allowed or not.

Enumerator
No 

Denotes non-recursive.

Yes 

Denotes recursion.

Definition at line 153 of file commonenumdefs.inl.

◆ Responsibility

enum class alib::lang::Responsibility : bool
strong

Denotes whether the responsibility for something is kept or passed. This is useful, e.g., in situations where objects are shared to determine if the responsibility for the deletion of object is transferred over to the receiver or kept by the sender of the object.

Enumerator
KeepWithSender 

Keeps responsibility, e.g., when passing an object.

Transfer 

Transfers responsibility to the receiving party.

Definition at line 164 of file commonenumdefs.inl.

◆ Safeness

enum class alib::lang::Safeness : bool
strong

Denotes whether something should be performed in a safe or unsafe fashion.

Enumerator
Safe 

Do it or treat it with safety.

Unsafe 

Omit checks or perform unsafe operations.

Definition at line 173 of file commonenumdefs.inl.

◆ Side

enum class alib::lang::Side : bool
strong

Denotes if something is left or right.

Enumerator
Left 

Denotes the left side of something.

Right 

Denotes the right side of something.

Definition at line 182 of file commonenumdefs.inl.

◆ SortOrder

enum class alib::lang::SortOrder : bool
strong

Denotes sort order.

Enumerator
Ascending 

Chooses ascending sort oder.

Descending 

Chooses descending sort oder.

Definition at line 191 of file commonenumdefs.inl.

◆ SourceData

enum class alib::lang::SourceData : bool
strong

Denotes if the source data should be moved or copied.

Enumerator
Copy 

Chooses not to clear existing data.

Move 

Chooses to clear existing data.

Definition at line 200 of file commonenumdefs.inl.

◆ Switch

enum class alib::lang::Switch : bool
strong

Denotes if sth. is switched on or off.

Enumerator
Off 

Switch it off, switched off, etc.

On 

Switch it on, switched on, etc.

Definition at line 209 of file commonenumdefs.inl.

◆ Timezone

enum class alib::lang::Timezone : bool
strong

Denotes whether a time value represents local time or UTC.

Enumerator
Local 

Denotes local time.

UTC 

Denotes UTC (coordinated universal time).

Definition at line 218 of file commonenumdefs.inl.

◆ Timing

enum class alib::lang::Timing
strong

Denotes if asynchronous tasks become synchronized.

Enumerator
Async 

The end of a transaction. Writes "Async", reads in addition "asynchronous", "no", "off", "false", "0" "-".

Sync 

The start of a transaction. Writes "Sync", reads in addition "synchronous", "synchronized", "synced" "yes", "on", "true", "1".

Definition at line 227 of file commonenumdefs.inl.

◆ ValueReference

enum class alib::lang::ValueReference
strong

Denotes if a value is interpreted as an absolute or relative number.

Enumerator
Absolute 

Referring to an absolute value.

Relative 

Referring to a relative value.

Definition at line 239 of file commonenumdefs.inl.

◆ Whitespaces

enum class alib::lang::Whitespaces : bool
strong

Denotes whether a string is trimmed or not.

Enumerator
Trim 

Trim whitespaces away.

Keep 

Keep whitespaces in string.

Definition at line 248 of file commonenumdefs.inl.

Function Details:

◆ BitCount()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::BitCount ( TIntegral value)
constexpr

Returns the number of bits set in an integral value. Internally, this method uses C++20 library function std::popcount.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test.
Returns
The number of bits set in a value.

Definition at line 222 of file bits.inl.

◆ bitsofval()

template<typename T>
int alib::lang::bitsofval ( const T & val)
inlineconstexpr

Like C++ keyword sizeof but returns the number of bits of the type of the given value. The return type is int instead of size_t, which satisfies ALib code conventions.

Note
To improve code readability, namely to a) indicate that this is an inlined, constant expression and b) to indicate that this is just using keyword sizeof, as an exception from the rules, this function is spelled in lower case.
See also
Macro bitsof(type), which works directly on the type.
Parameters
valThe (sample) value to deduce the type from. Otherwise ignored.
Template Parameters
TThe type to receive the size in bits from.
Returns
The size of TIntegral in bits.

Definition at line 35 of file bits.inl.

◆ CLZ()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::CLZ ( TIntegral value)
constexpr

Returns the number of the leading 0-bits in an integral type. Internally, this method uses C++20 library function std::countl_zero.

Attention
This function must not be called with a value of 0! In debug-compilations, this method raises an ALib error in this case, while in release-compilations, the result is 'undefined'. With function MSB0, an alternative is given which returns 0 if the input is 0.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. Must not be 0.
Returns
The highest bit set in value.

Definition at line 239 of file bits.inl.

◆ CLZ0()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::CLZ0 ( TIntegral value)
constexpr

Variant of CLZ which tests the given parameter value on 0 and returns sizeof(TIntegral) * 8 in this case. Otherwise, returns the result of CLZ.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. May be 0, which results to the number of bits in TIntegral.
Returns
The number of leading zero-bits in value.

Definition at line 259 of file bits.inl.

Here is the call graph for this function:

◆ CTZ()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::CTZ ( TIntegral value)
constexpr

Returns the number of the trailing 0-bits in an integral type. Internally, this method uses C++20 library function std::countr_zero.

Attention
This function must not be called with a value of 0! In debug-compilations, this method raises an ALib error in this case, while in release-compilations, the result is 'undefined'. With function CTZ0, an alternative is given which returns 0 if the input is 0.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. Must not be 0.
Returns
The lowest bit set in value.

Definition at line 280 of file bits.inl.

◆ CTZ0()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::CTZ0 ( TIntegral value)
constexpr

Variant of CTZ which tests given parameter value on 0 and returns sizeof(TIntegral) * 8 in this case. Otherwise, returns the result of CLZ.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. May be 0, which results to the number of bits in TIntegral.
Returns
The number of trailing zero-bits in value. In case the given value is 0, sizeof(Tintegral) * 8 is returned.

Definition at line 298 of file bits.inl.

Here is the call graph for this function:

◆ Destruct()

template<typename T>
void alib::lang::Destruct ( T & object)
inline

This static inline namespace function calls the destructor ~T()of given object. The use of this method is recommended instead of calling the destructor directly, to increase readability of the code.

Attention
Pointers have to be dereferenced when passed as arguments. Otherwise, this method does nothing, as the "destructor of a pointer" is called.
Because, for example, container types would pass a pointer here, in case their (custom) stored type is a pointer type, no static assertion can be made here.
Template Parameters
TThe object type. Deduced by the compiler and not need to be given.
Parameters
objectThe object to destruct.

Definition at line 83 of file tmp.inl.

◆ IsNotNull()

template<typename T>
requires std::default_initializable<T>
bool alib::lang::IsNotNull ( const T & t)
constexpr

The negation of alib::lang::IsNull.

Parameters
tThe instance to test.
Returns
false if t is default-constructed, true otherwise.

Definition at line 56 of file tmp.inl.

◆ IsNull()

template<typename T>
requires std::default_initializable<T>
bool alib::lang::IsNull ( const T & t)
constexpr

Checks if a given object equals a default-constructed value of the same type. This function is useful with types that are not otherwise testable, for example, type std::thread::id.

Parameters
tThe instance to test.
Returns
true if t is default-constructed, false otherwise.

Definition at line 49 of file tmp.inl.

◆ Log2OfSize()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::Log2OfSize ( )
constexpr

Returns logarithm base 2 for the size in bits of the template given integral type.

Precisely, this function returns:

  • 3 for 8-bit types,
  • 4 for 16-bit types,
  • 5 for 32-bit types,
  • 6 for 64-bit types, and
  • 7 for 128-bit types.
    Template Parameters
    TIntegralThe integral type to count bits in.
    Returns
    The number of bits needed to count the bits of type TIntegral.

Definition at line 205 of file bits.inl.

◆ LowerBits() [1/2]

template<typename TIntegral>
requires std::integral<TIntegral>
TIntegral alib::lang::LowerBits ( ShiftOpRHS width,
TIntegral value )
constexpr

Inline namespace function that keeps the given number of lower bits and masks the higher ones out of the given integral value. Parameter width must not be greater or equal to the width of the given TIntegral type. In debug compilations, an error is raised.

See also
A fully templated version usable when the number of bits are known at compile time, is given with LowerBits<ShiftOpRHS,TIntegral>().
Parameters
widthThe number of lower bits to keep.
valueThe value to mask.
Template Parameters
TIntegralThe integral type to operate on (deduced by the compiler).
Returns
The given value with the upper remaining bits cleared.

Definition at line 190 of file bits.inl.

Here is the call graph for this function:

◆ LowerBits() [2/2]

template<ShiftOpRHS TWidth, typename TIntegral>
requires std::integral<TIntegral>
TIntegral alib::lang::LowerBits ( TIntegral value)
constexpr

Inline namespace function that keeps the given number of lower bits and masks the higher ones out of the given integral value. If parameter TWidth is greater or equal to the width of the given TIntegral type, then all bits are returned.

See also
While this is the fully templated version and hence explicitly constexpression for the reader of a code, with alib::lang::LowerBits<TIntegral>(lang::ShiftOpRHS,TIntegral), a version is given.
Parameters
valueThe value to mask.
Template Parameters
TWidthThe number of lower bits to keep.
TIntegralThe integral type to operate on (deduced by the compiler).
Returns
The given value with the upper remaining bits cleared.

Definition at line 169 of file bits.inl.

Here is the call graph for this function:

◆ LowerMask() [1/3]

template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth < bitsof(TIntegral) )
TIntegral alib::lang::LowerMask ( )
constexpr

Inline namespace function that returns a mask with bits set to 1 up to the given binary digit, and bits above to 0. If parameter TWidth is greater or equal to the width of the given TIntegral type, then all bits are set in the returned value.

See also
While this is the fully templated version, with alib::lang::LowerMask<TIntegral>(ShiftOpRHS), a run-time version is given.
Template Parameters
TWidthThe number of lower bits to set to 1.
TIntegralThe integral type to operate on.
Returns
The requested mask.

Definition at line 53 of file bits.inl.

◆ LowerMask() [2/3]

template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth >= bitsof(TIntegral) )
TIntegral alib::lang::LowerMask ( )
constexpr

Overloaded version handling bit-overflow.

See also
Template Parameters
TWidthThe number of lower bits to set to 1.
TIntegralThe integral type to operate on.
Returns
The requested mask.

Definition at line 72 of file bits.inl.

◆ LowerMask() [3/3]

template<typename TIntegral>
requires std::integral<TIntegral>
TIntegral alib::lang::LowerMask ( ShiftOpRHS width)
constexpr

Inline namespace function that returns a mask with bits set to 1 up to the given binary digit, and bits above to 0. Parameter width must not be greater or equal to the width of the given TIntegral type. In debug-compilations, an error is raised in that case.

See also
A fully templated version usable when the number of bits are known at compile time, is given with LowerMask<ShiftOpRHS,typename>().
Template Parameters
TIntegralThe integral type to operate on.
Parameters
widthThe number of lower bits to set in the mask returned.
Returns
The requested mask.

Definition at line 89 of file bits.inl.

◆ MSB()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::MSB ( TIntegral value)
constexpr

Returns the number of the most significant bit in an integral type. Internally, this method uses CLZ and returns

 int(sizeof(TIntegral)) * 8 - CLZ(value)
Attention
This function must not be called with a value of 0! In debug-compilations, this method raises an ALib error in this case, while in release-compilations, the result is 'undefined'. With function MSB0, an alternative is given which returns 0 if the input is 0.
Note
A corresponding function "LSB", to receive the least significant bit is not given. Instead, use CTZ() + 1.
Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. Must not be 0.
Returns
The highest bit set in value. The numbering starts with 1 and ends with sizeof(Tintegral) * 8.

Definition at line 325 of file bits.inl.

Here is the call graph for this function:

◆ MSB0()

template<typename TIntegral>
requires std::integral<TIntegral>
int alib::lang::MSB0 ( TIntegral value)
constexpr

Variant of MSB which tests given parameter value on 0 and returns 0 in this case. Otherwise, returns the result of MSB.

Template Parameters
TIntegralThe integral type to operate on.
Parameters
valueThe value to test. May be 0, which results to 0.
Returns
The highest bit set in value. The numbering starts with 1 and ends with sizeof(Tintegral)* 8. If value is 0, hence no bit is set, 0 is returned.

Definition at line 344 of file bits.inl.

Here is the call graph for this function:

◆ operator&()

template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > alib::lang::operator& ( const alib::lang::TBitSet< TInterface, TEnd, TBegin > & lhs,
const alib::lang::TBitSet< TInterface, TEnd, TBegin > & rhs )
constexprnoexcept

Performs binary AND operation two TBitSet objects (of equal size), lhs and rhs.

Note
This operator function is located in the global namespace. The documentation shows namespace alib, which is done for the purposes of organizing the manual index better.
Parameters
lhsThe left hand side operand.
rhsThe right hand side operand.
Template Parameters
TEndTemplate parameter of class TBitSet. Deduced by the compiler.
TBeginTemplate parameter of class TBitSet. Deduced by the compiler.
TInterfaceTemplate parameter of class TBitSet. Deduced by the compiler.
Returns
A temporary TBitSet containing the result of the operation.

Definition at line 900 of file bitset.inl.

Here is the call graph for this function:

◆ operator^()

template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > alib::lang::operator^ ( const alib::lang::TBitSet< TInterface, TEnd, TBegin > & lhs,
const alib::lang::TBitSet< TInterface, TEnd, TBegin > & rhs )
constexprnoexcept

Performs binary XOR operation two TBitSet objects (of equal size), lhs and rhs.

Note
This operator function is located in the global namespace. The documentation shows namespace alib, which is done for the purposes of organizing the manual index better.
Parameters
lhsThe left hand side operand.
rhsThe right hand side operand.
Template Parameters
TEndTemplate parameter of class TBitSet. Deduced by the compiler.
TBeginTemplate parameter of class TBitSet. Deduced by the compiler.
TInterfaceTemplate parameter of class TBitSet. Deduced by the compiler.
Returns
A temporary TBitSet containing the result of the operation.

Definition at line 952 of file bitset.inl.

Here is the call graph for this function:

◆ operator|()

template<typename TInterface, TInterface TEnd, TInterface TBegin>
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > alib::lang::operator| ( const alib::lang::TBitSet< TInterface, TEnd, TBegin > & lhs,
const alib::lang::TBitSet< TInterface, TEnd, TBegin > & rhs )
constexprnoexcept

Performs binary OR operation two TBitSet objects (of equal size), lhs and rhs.

Note
This operator function is located in the global namespace. The documentation shows namespace alib, which is done for the purposes of organizing the manual index better.
Parameters
lhsThe left hand side operand.
rhsThe right hand side operand.
Template Parameters
TEndTemplate parameter of class TBitSet. Deduced by the compiler.
TBeginTemplate parameter of class TBitSet. Deduced by the compiler.
TInterfaceTemplate parameter of class TBitSet. Deduced by the compiler.
Returns
A temporary TBitSet containing the result of the operation.

Definition at line 926 of file bitset.inl.

Here is the call graph for this function:

◆ SafeCast()

template<typename TTo, typename TFrom>
ALIB_WARNINGS_RESTORE TTo * alib::lang::SafeCast ( TFrom * derived)

Cast function that chooses either static_cast or dynamic_cast, dependent on whether type TTo is polymorphic or not.

Template Parameters
TToThe type to cast down to.
TFromThe type to cast from.
Parameters
derivedA pointer to the derived type.
Returns
A pointer to the base type.

Definition at line 31 of file tmp.inl.

◆ SetNull()

template<typename T>
requires std::default_initializable<T>
void alib::lang::SetNull ( T & t)
constexpr

Assigns a default-constructed value to the given instance. This function is useful with types that are not otherwise nullable, for example, type std::thread::id.

Parameters
tThe instance to test.

Definition at line 64 of file tmp.inl.

◆ UpperMask() [1/3]

template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth < bitsof(TIntegral) )
TIntegral alib::lang::UpperMask ( )
constexpr

Inline namespace function that returns a mask with bits set to 0 up to the given binary digit, and bits above to 1. If parameter TWidth is greater or equal to the width of the given TIntegral type, then all bits are set in the returned value.

See also
While this is the fully templated version, with alib::lang::UpperMask<TIntegral>(ShiftOpRHS), a run-time version is given.
Template Parameters
TWidthThe number of lower bits to clear to 1.
TIntegralThe integral type to operate on.
Returns
The requested mask.

Definition at line 111 of file bits.inl.

◆ UpperMask() [2/3]

template<ShiftOpRHS TWidth, typename TIntegral>
requires ( std::is_integral<TIntegral>::value && TWidth >= bitsof(TIntegral) )
TIntegral alib::lang::UpperMask ( )
constexpr

Overloaded version handling bit-overflow.

See also
Template Parameters
TWidthThe number of lower bits to set to 1.
TIntegralThe integral type to operate on.
Returns
The requested mask.

Definition at line 128 of file bits.inl.

◆ UpperMask() [3/3]

template<typename TIntegral>
requires std::integral<TIntegral>
TIntegral alib::lang::UpperMask ( ShiftOpRHS width)
constexpr

Inline namespace function that returns a mask with bits set to 0 up to the given binary digit, and bits above to 1. Parameter width must not be greater or equal to the width of the given TIntegral type. In debug compilations, an error is raised in that case.

See also
A fully templated version usable when the number of bits are known at compile time, is given with UpperMask<ShiftOpRHS,typename>().
Template Parameters
TIntegralThe integral type to operate on.
Parameters
widthThe number of lower bits to clear in the mask returned.
Returns
The requested mask.

Definition at line 145 of file bits.inl.

Variable Details:

◆ DBG_CRITICAL_SECTION_YIELD_OR_SLEEP_TIME_IN_NS

unsigned int alib::lang::DBG_CRITICAL_SECTION_YIELD_OR_SLEEP_TIME_IN_NS

This external variable is available only if the compiler-symbol ALIB_DEBUG_CRITICAL_SECTIONS is set and module ALib Threads is included in the ALib Build.
When it is 0, which is the default, nothing is done.
When it is 1, then Thread::YieldToSystem is invoked with interface methods of class DbgCriticalSections.
Other values are passed to a call to Thread::SleepNanos.

The purpose of this debug-feature is to be better able to detect non-protected concurrent access to critical sections. With increasing the time slice that a thread remains in a critical section, the probability to be caught by another thread is increased.

Definition at line 28 of file dbgcriticalsections.cpp.