![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
Diverse extensions of fundamental types.

INTEGRAL TYPES EXTENSIONS | |
| enum class | elementa::base::endian { little = 0 , big = 1 , native = little } |
| Endianness of the target machine, as defined in the C++20 standard. More... | |
| enum class | elementa::base::SignSpec : uint8_t { kSigned = 0 , kUnsigned } |
| Defines the possible sign of a fundamental (integral) type. More... | |
| using | elementa::base::sizebits_t = unsigned |
| Type able to index all bits in the longest int. type in the target machine. More... | |
| using | elementa::base::sizebytes_t = unsigned |
| Type able to index all bytes in the longest int. type in the target machine. More... | |
| using | elementa::base::LongestUnsigned = unsigned long long |
| Longest unsigned integral type in the target machine. More... | |
| using | elementa::base::LongestInt = long long |
| Longest signed integral type in the target machine. More... | |
| using | elementa::base::LongestReal = long double |
| Longest real type. More... | |
| template<sizebits_t NBITS, SignSpec SIGN> | |
| using | elementa::base::ExactInteger = typename std::conditional<((NBITS==8) &&(SIGN==SignSpec::kSigned)), int8_t, typename std::conditional<((NBITS==8) &&(SIGN==SignSpec::kUnsigned)), uint8_t, typename std::conditional<((NBITS==16) &&(SIGN==SignSpec::kSigned)), int16_t, typename std::conditional<((NBITS==16) &&(SIGN==SignSpec::kUnsigned)), uint16_t, typename std::conditional<((NBITS==32) &&(SIGN==SignSpec::kSigned) &&(kMaxBitsInt > 16)), int32_t, typename std::conditional<((NBITS==32) &&(SIGN==SignSpec::kUnsigned) &&(kMaxBitsInt > 16)), uint32_t, typename std::conditional<((NBITS==64) &&(SIGN==SignSpec::kSigned) &&(kMaxBitsInt > 32)), int64_t, typename std::conditional<((NBITS==64) &&(SIGN==SignSpec::kUnsigned) &&(kMaxBitsInt > 32)), uint64_t, void >::type >::type >::type >::type >::type >::type >::type >::type |
| To get an int. type with given characteristics of number of bits and sign. More... | |
| constexpr sizebits_t | elementa::base::kMaxBitsInt = 16 |
| Maximum number of bits in an integer type in the target machine. More... | |
| constexpr sizebits_t | elementa::base::kLeastSizeForBits (sizebits_t nbs) |
| Shortest integral type for holding a number of bits in the target machine. More... | |
| template<typename I > | |
| constexpr I | elementa::base::kNBitsSet (sizebits_t n) |
| Compute an integral constant with its N least-significant bits set. More... | |
| uint8_t | elementa::base::len_for_bits (uint8_t nbits) |
| Maximum number of digits needed for the decimal form of NBITS binary numbers. | |
| template<typename T > | |
| sizebits_t | elementa::base::count_bits (T v) |
| Count the number of bits that are set in an integral value. More... | |
| template<typename T , sizebits_t N = sizeof(T)*CHAR_BIT> | |
| sizebits_t | elementa::base::most_significant_bit (T b) |
| Return the index of the MSb set in B, or the number of bits in T if none. More... | |
| template<typename PT > | |
| const PT * | elementa::base::kPtrPlusBytes (const PT *p, size_t boff) |
| Add a number of bytes to the address of a pointer without changing its type. More... | |
| LongestUnsigned | elementa::base::to_number (const void *p) |
| Convert a pointer address to a number. | |
| int | elementa::base::to_number (char n) |
| Convert a char into a number (useful for printing, for ex.). | |
| unsigned | elementa::base::to_number (unsigned char n) |
| Convert an unsigned char into a number (useful for printing, for ex.). | |
| using elementa::base::sizebits_t = typedef unsigned |
#include <elementa/base/fundamentaltypes.h>
Type able to index all bits in the longest int. type in the target machine.
This type is not signed, just like size_t is defined as not signed in the C++ standard.
Definition at line 102 of file fundamentaltypes.h.
| using elementa::base::sizebytes_t = typedef unsigned |
#include <elementa/base/fundamentaltypes.h>
Type able to index all bytes in the longest int. type in the target machine.
This type is not signed, just like size_t is defined as not signed in the C++ standard.
Definition at line 111 of file fundamentaltypes.h.
| using elementa::base::LongestUnsigned = typedef unsigned long long |
#include <elementa/base/fundamentaltypes.h>
Longest unsigned integral type in the target machine.
This type is useful, for example, to receive an integral argument that can have any length. For indicating a size in memory, use size_t instead: the standard states, in fact, that any object in memory that occupies more than size_t is ill formed.
Definition at line 118 of file fundamentaltypes.h.
| using elementa::base::LongestInt = typedef long long |
#include <elementa/base/fundamentaltypes.h>
Longest signed integral type in the target machine.
Definition at line 121 of file fundamentaltypes.h.
| using elementa::base::LongestReal = typedef long double |
#include <elementa/base/fundamentaltypes.h>
Longest real type.
Definition at line 124 of file fundamentaltypes.h.
| using elementa::base::ExactInteger = typedef typename std::conditional< ((NBITS == 8) && (SIGN==SignSpec::kSigned)), int8_t, typename std::conditional< ((NBITS == 8) && (SIGN==SignSpec::kUnsigned)), uint8_t, typename std::conditional< ((NBITS == 16) && (SIGN==SignSpec::kSigned)), int16_t, typename std::conditional< ((NBITS == 16) && (SIGN==SignSpec::kUnsigned)), uint16_t, typename std::conditional< ((NBITS == 32) && (SIGN==SignSpec::kSigned) && (kMaxBitsInt > 16)), int32_t, typename std::conditional< ((NBITS == 32) && (SIGN==SignSpec::kUnsigned) && (kMaxBitsInt > 16)), uint32_t, typename std::conditional< ((NBITS == 64) && (SIGN==SignSpec::kSigned) && (kMaxBitsInt > 32)), int64_t, typename std::conditional< ((NBITS == 64) && (SIGN==SignSpec::kUnsigned) && (kMaxBitsInt > 32)), uint64_t, void >::type >::type >::type >::type >::type >::type >::type >::type |
#include <elementa/base/fundamentaltypes.h>
To get an int. type with given characteristics of number of bits and sign.
This is useful in those cases where a program needs those characteristics but they are not fixed yet when the programmer writes the code.
Definition at line 191 of file fundamentaltypes.h.
|
strong |
#include <elementa/base/fundamentaltypes.h>
Endianness of the target machine, as defined in the C++20 standard.
Defined here since this machine has no c++20 support. See https://en.cppreference.com/w/cpp/types/endian This class indicates the endianness of all scalar types:
Corner case platforms are also supported:
Definition at line 74 of file fundamentaltypes.h.
|
strong |
#include <elementa/base/fundamentaltypes.h>
Defines the possible sign of a fundamental (integral) type.
Definition at line 134 of file fundamentaltypes.h.
|
constexpr |
#include <elementa/base/fundamentaltypes.h>
Shortest integral type for holding a number of bits in the target machine.
Return the number of bits of the shortest integral type existing in the target machine that at least is capable of holding NBS bits. Return 0 if the requested number of bits cannot be held in any target machine integral type.
Definition at line 171 of file fundamentaltypes.h.
|
constexpr |
#include <elementa/base/fundamentaltypes.h>
Compute an integral constant with its N least-significant bits set.
| I | is a type that must be long enough to hold n+1 bits. |
Definition at line 226 of file fundamentaltypes.h.
| sizebits_t elementa::base::count_bits | ( | T | v | ) |
#include <elementa/base/fundamentaltypes.h>
Count the number of bits that are set in an integral value.
Definition at line 248 of file fundamentaltypes.h.
| sizebits_t elementa::base::most_significant_bit | ( | T | b | ) |
#include <elementa/base/fundamentaltypes.h>
Return the index of the MSb set in B, or the number of bits in T if none.
Definition at line 267 of file fundamentaltypes.h.
| const PT * elementa::base::kPtrPlusBytes | ( | const PT * | p, |
| size_t | boff | ||
| ) |
#include <elementa/base/fundamentaltypes.h>
Add a number of bytes to the address of a pointer without changing its type.
| PT | is the pointed type, not the pointer type |
Definition at line 290 of file fundamentaltypes.h.
|
constexpr |
#include <elementa/base/fundamentaltypes.h>
Maximum number of bits in an integer type in the target machine.
Definition at line 156 of file fundamentaltypes.h.