GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
fundamentals.hpp File Reference

Go to the source code of this file.

Classes

struct  grem::Limits< T >
struct  grem::Limits< T >
struct  grem::ValueRepresentation< T >
struct  grem::Limits< bool8_t >
class  grem::bool16_t
struct  grem::Limits< bool16_t >
class  grem::bool32_t
struct  grem::Limits< bool32_t >
class  grem::bool64_t
struct  grem::Limits< bool64_t >
struct  grem::float16_t
struct  grem::Limits< float16_t >

Namespaces

namespace  grem

Typedefs

using grem::ssize_t = std::make_signed_t<size_t>
using grem::bool8_t = bool
using grem::float32_t = float
using grem::float64_t = double
using grem::i8norm = detail::NormalizedInteger<int8_t>
using grem::u8norm = detail::NormalizedInteger<uint8_t>
using grem::i16norm = detail::NormalizedInteger<int16_t>
using grem::u16norm = detail::NormalizedInteger<uint16_t>

Enumerations

enum  : bool8_t { grem::false8 = false , grem::true8 = true }

Functions

template<strict_integral T>
GREM_ALWAYS_INLINE constexpr T grem::getBitReversed (T value)
 Get a copy of an integer with its bit order reversed.
template<typename T>
GREM_ALWAYS_INLINE constexpr T grem::getByteReversed (T value)
 Get a copy of a value with its byte order reversed.
template<typename T>
GREM_ALWAYS_INLINE constexpr T grem::convertHostEndianToBigEndian (T value)
 Convert a value in host-endian byte order to the corresponding value in big-endian byte order.
template<typename T>
GREM_ALWAYS_INLINE constexpr T grem::convertHostEndianToLittleEndian (T value)
 Convert a value in host-endian byte order to the corresponding value in little-endian byte order.
template<typename T>
GREM_ALWAYS_INLINE constexpr T grem::convertBigEndianToHostEndian (T value)
 Convert a value in big-endian byte order to the corresponding value in host-endian byte order.
template<typename T>
GREM_ALWAYS_INLINE constexpr T grem::convertLittleEndianToHostEndian (T value)
 Convert a value in little-endian byte order to the corresponding value in host-endian byte order.
template<strict_arithmetic T>
GREM_ALWAYS_INLINE constexpr T grem::midpoint (T a, T b)
 Get the midpoint between two values.
template<typename A, typename B>
requires (requires(A x, B y) { x < y; })
GREM_ALWAYS_INLINE constexpr decltype(auto) grem::min (A &&a, B &&b)
 Get the smaller of two values, or the first value if they are equivalent.
template<typename A, typename B>
requires (requires(A x, B y) { x < y; })
GREM_ALWAYS_INLINE constexpr decltype(auto) grem::max (A &&a, B &&b)
 Get the greater of two values, or the first value if they are equivalent.
template<typename A, typename B>
requires (requires(A x, B y) { x < y; })
GREM_ALWAYS_INLINE constexpr auto grem::minmax (A &&a, B &&b)
 Get the smaller and greater of two values.
template<typename T, typename Low, typename High>
requires (requires(T v, Low l) { v < l; } && requires(T v, High h) { h < v; })
GREM_ALWAYS_INLINE constexpr decltype(auto) grem::clamp (T &&value, Low &&minValue, High &&maxValue)
 Clamp a value to a specific interval.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::rotateBitsLeft (UnsignedInteger value, int shift) noexcept
 Get the result of bitwise left-rotating a value by a number of bits.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::rotateBitsRight (UnsignedInteger value, int shift) noexcept
 Get the result of bitwise right-rotating a value by a number of bits.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countOneBits (UnsignedInteger value) noexcept
 Get the number of 1 bits in a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countZeroBits (UnsignedInteger value) noexcept
 Get the number of 0 bits in a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countLeadingZeroBits (UnsignedInteger value) noexcept
 Get the number of consecutive 0 bits starting at the most significant (leftmost) bit of a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countLeadingOneBits (UnsignedInteger value) noexcept
 Get the number of consecutive 1 bits starting at the most significant (leftmost) bit of a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countTrailingZeroBits (UnsignedInteger value) noexcept
 Get the number of consecutive 0 bits starting at the least significant (rightmost) bit of a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::countTrailingOneBits (UnsignedInteger value) noexcept
 Get the number of consecutive 1 bits starting at the least significant (rightmost) bit of a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr int grem::getRequiredBitCount (UnsignedInteger value) noexcept
 Get the minimum number of bits required to represent a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::getMaxValueForBits (size_t bits) noexcept
 Get the maximum value that can be represented in a given unsigned integer type using a given number of bits.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr bool grem::isPowerOf2 (UnsignedInteger value) noexcept
 Check if a given integer is a power of 2, i.e. if the number appears in the infinite sequence 2^0, 2^1, 2^2, ..., 2^n.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::roundUpToPowerOf2 (UnsignedInteger value) noexcept
 Get the smallest integral power of 2 that is not less than a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::roundDownToPowerOf2 (UnsignedInteger value) noexcept
 Get the largest integral power of 2 that is not greater than a given value.
template<strict_unsigned_integral UnsignedInteger>
GREM_ALWAYS_INLINE constexpr UnsignedInteger grem::roundUpToMultiple (UnsignedInteger value, UnsignedInteger n)
 Get the smallest multiple of n that is not greater than a given value.

Variables

constexpr size_t grem::BYTE_BITS = CHAR_BIT
constexpr bool16_t grem::false16 {false}
constexpr bool16_t grem::true16 {true}
constexpr bool32_t grem::false32 {false}
constexpr bool32_t grem::true32 {true}
constexpr bool64_t grem::false64 {false}
constexpr bool64_t grem::true64 {true}
constexpr bool grem::HOST_IS_LITTLE_ENDIAN = std::endian::native == std::endian::little
 Whether the host system's native byte order is little-endian or not.
constexpr bool grem::HOST_IS_BIG_ENDIAN = std::endian::native == std::endian::big
 Whether the host system's native byte order is big-endian or not.