![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
#include "elementa/license.inc"#include "elementa/checks.inc"#include <cstdint>#include <climits>#include <cstddef>#include <type_traits>#include <cmath>

Go to the source code of this file.
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.). | |