Blender V5.0
blender::fixed_width_int Namespace Reference

Classes

struct  UIntF
struct  IntF
struct  DoubleUIntType
struct  DoubleUIntType< uint8_t >
struct  DoubleUIntType< uint16_t >
struct  DoubleUIntType< uint32_t >
struct  DoubleUIntType< uint64_t >

Typedefs

template<typename T>
using double_uint_type = typename DoubleUIntType<T>::type
using UInt64_8 = UIntF<uint8_t, 8>
using UInt64_16 = UIntF<uint16_t, 4>
using UInt64_32 = UIntF<uint32_t, 2>
using Int64_8 = IntF<uint8_t, 8>
using Int64_16 = IntF<uint16_t, 4>
using Int64_32 = IntF<uint32_t, 2>
using UInt128_8 = UIntF<uint8_t, 16>
using UInt128_16 = UIntF<uint16_t, 8>
using UInt128_32 = UIntF<uint32_t, 4>
using UInt128_64 = UIntF<uint64_t, 2>
using UInt256_8 = UIntF<uint8_t, 32>
using UInt256_16 = UIntF<uint16_t, 16>
using UInt256_32 = UIntF<uint32_t, 8>
using UInt256_64 = UIntF<uint64_t, 4>
using Int128_8 = IntF<uint8_t, 16>
using Int128_16 = IntF<uint16_t, 8>
using Int128_32 = IntF<uint32_t, 4>
using Int128_64 = IntF<uint64_t, 2>
using Int256_8 = IntF<uint8_t, 32>
using Int256_16 = IntF<uint16_t, 16>
using Int256_32 = IntF<uint32_t, 8>
using Int256_64 = IntF<uint64_t, 4>
using UInt128 = UInt128_64
using UInt256 = UInt256_64
using Int128 = Int128_64
using Int256 = Int256_64

Functions

template<typename T, typename T2, int S>
void generic_add (T *__restrict dst, const T *a, const T *b)
template<typename T, typename T2, int S>
void generic_sub (T *__restrict dst, const T *a, const T *b)
template<typename T, typename T2, int S>
void generic_unsigned_mul (T *__restrict dst, const T *a, const T *b)
template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
UIntF< T, Size > operator+ (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
IntF< T, Size > operator+ (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
UIntF< T, Size > operator- (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
IntF< T, Size > operator- (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
UIntF< T, Size > operator* (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
bool is_negative (const IntF< T, Size > &a)
template<typename T, int Size>
bool is_zero (const UIntF< T, Size > &a)
template<typename T, int Size>
bool is_zero (const IntF< T, Size > &a)
template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
IntF< T, Size > operator* (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
IntF< T, Size > operator- (const IntF< T, Size > &a)
template<typename T, int Size>
void operator+= (UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
void operator+= (IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
void operator-= (UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
void operator-= (IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
void operator*= (UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
void operator*= (IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator== (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator== (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
bool operator!= (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator!= (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, size_t Size>
int compare_reversed_order (const std::array< T, Size > &a, const std::array< T, Size > &b)
template<typename T, int Size>
bool operator< (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator<= (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator> (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator>= (const IntF< T, Size > &a, const IntF< T, Size > &b)
template<typename T, int Size>
bool operator< (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
bool operator<= (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
bool operator> (const UIntF< T, Size > &a, const UIntF< T, Size > &b)
template<typename T, int Size>
bool operator>= (const UIntF< T, Size > &a, const UIntF< T, Size > &b)

Typedef Documentation

◆ double_uint_type

template<typename T>
using blender::fixed_width_int::double_uint_type = typename DoubleUIntType<T>::type

Maps unsigned integer types to a type that's twice the size. E.g. uint16_t to uint32_t.

Definition at line 127 of file BLI_fixed_width_int.hh.

◆ Int128

◆ Int128_16

Definition at line 148 of file BLI_fixed_width_int.hh.

◆ Int128_32

Definition at line 149 of file BLI_fixed_width_int.hh.

◆ Int128_64

◆ Int128_8

Definition at line 147 of file BLI_fixed_width_int.hh.

◆ Int256

◆ Int256_16

Definition at line 153 of file BLI_fixed_width_int.hh.

◆ Int256_32

Definition at line 154 of file BLI_fixed_width_int.hh.

◆ Int256_64

◆ Int256_8

Definition at line 152 of file BLI_fixed_width_int.hh.

◆ Int64_16

Definition at line 134 of file BLI_fixed_width_int.hh.

◆ Int64_32

Definition at line 135 of file BLI_fixed_width_int.hh.

◆ Int64_8

Definition at line 133 of file BLI_fixed_width_int.hh.

◆ UInt128

◆ UInt128_16

Definition at line 138 of file BLI_fixed_width_int.hh.

◆ UInt128_32

Definition at line 139 of file BLI_fixed_width_int.hh.

◆ UInt128_64

◆ UInt128_8

Definition at line 137 of file BLI_fixed_width_int.hh.

◆ UInt256

◆ UInt256_16

Definition at line 143 of file BLI_fixed_width_int.hh.

◆ UInt256_32

Definition at line 144 of file BLI_fixed_width_int.hh.

◆ UInt256_64

◆ UInt256_8

Definition at line 142 of file BLI_fixed_width_int.hh.

◆ UInt64_16

Definition at line 130 of file BLI_fixed_width_int.hh.

◆ UInt64_32

Definition at line 131 of file BLI_fixed_width_int.hh.

◆ UInt64_8

Definition at line 129 of file BLI_fixed_width_int.hh.

Function Documentation

◆ compare_reversed_order()

template<typename T, size_t Size>
int blender::fixed_width_int::compare_reversed_order ( const std::array< T, Size > & a,
const std::array< T, Size > & b )
inline

Definition at line 488 of file BLI_fixed_width_int.hh.

References b, and i.

Referenced by operator<(), operator<(), operator<=(), operator<=(), operator>(), operator>(), operator>=(), and operator>=().

◆ generic_add()

template<typename T, typename T2, int S>
void blender::fixed_width_int::generic_add ( T *__restrict dst,
const T * a,
const T * b )
inline

Adds two fixed-width-integer together using the standard addition with carry algorithm taught in schools. The main difference is that the digits here are not 0 to 9, but 0 to max(T).

Due to the design of two's-complement numbers, this works for signed and unsigned fixed-width-integer. The overflow behavior is wrap-around.

Parameters
TType for individual digits.
T2Integer type that is twice as large as T.
SNumber of digits of type T in each fixed-width-integer.

Definition at line 285 of file BLI_fixed_width_int.hh.

References b, i, T, T2, and blender::unroll().

Referenced by operator+(), and operator+().

◆ generic_sub()

template<typename T, typename T2, int S>
void blender::fixed_width_int::generic_sub ( T *__restrict dst,
const T * a,
const T * b )
inline

Similar to generic_add, but for subtraction.

Definition at line 302 of file BLI_fixed_width_int.hh.

References b, i, T, T2, and blender::unroll().

Referenced by operator-(), and operator-().

◆ generic_unsigned_mul()

template<typename T, typename T2, int S>
void blender::fixed_width_int::generic_unsigned_mul ( T *__restrict dst,
const T * a,
const T * b )
inline

Similar to generic_add, but for unsigned multiplication.

Definition at line 316 of file BLI_fixed_width_int.hh.

References b, i, T, and T2.

Referenced by operator*().

◆ is_negative()

template<typename T, int Size>
bool blender::fixed_width_int::is_negative ( const IntF< T, Size > & a)

Using this function is faster than using the comparison operator. Only a single bit has to be checked to determine if the value is negative.

Definition at line 384 of file BLI_fixed_width_int.hh.

References T, and blender::fixed_width_int::IntF< T, S >::v.

Referenced by blender::fixed_width_int::IntF< T, S >::operator double(), operator*(), operator<(), operator<=(), operator>(), and operator>=().

◆ is_zero() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::is_zero ( const IntF< T, Size > & a)
inline

◆ is_zero() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::is_zero ( const UIntF< T, Size > & a)
inline

◆ operator!=() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator!= ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 476 of file BLI_fixed_width_int.hh.

References b, and blender::fixed_width_int::IntF< T, S >::v.

◆ operator!=() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator!= ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

Definition at line 482 of file BLI_fixed_width_int.hh.

References b, and blender::fixed_width_int::UIntF< T, S >::v.

◆ operator*() [1/2]

template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
IntF< T, Size > blender::fixed_width_int::operator* ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 404 of file BLI_fixed_width_int.hh.

References b, and is_negative().

◆ operator*() [2/2]

template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
UIntF< T, Size > blender::fixed_width_int::operator* ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator*=() [1/2]

template<typename T, int Size>
void blender::fixed_width_int::operator*= ( IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 458 of file BLI_fixed_width_int.hh.

References b.

◆ operator*=() [2/2]

template<typename T, int Size>
void blender::fixed_width_int::operator*= ( UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

Definition at line 453 of file BLI_fixed_width_int.hh.

References b.

◆ operator+() [1/2]

template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
IntF< T, Size > blender::fixed_width_int::operator+ ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator+() [2/2]

template<typename T, int Size, BLI_ENABLE_IF((!std::is_void_v< double_uint_type< T > >))>
UIntF< T, Size > blender::fixed_width_int::operator+ ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator+=() [1/2]

template<typename T, int Size>
void blender::fixed_width_int::operator+= ( IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 438 of file BLI_fixed_width_int.hh.

References b.

◆ operator+=() [2/2]

template<typename T, int Size>
void blender::fixed_width_int::operator+= ( UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

Definition at line 433 of file BLI_fixed_width_int.hh.

References b.

◆ operator-() [1/3]

template<typename T, int Size>
IntF< T, Size > blender::fixed_width_int::operator- ( const IntF< T, Size > & a)
inline

Definition at line 424 of file BLI_fixed_width_int.hh.

References i, and result.

◆ operator-() [2/3]

template<typename T, int Size>
IntF< T, Size > blender::fixed_width_int::operator- ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator-() [3/3]

template<typename T, int Size>
UIntF< T, Size > blender::fixed_width_int::operator- ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator-=() [1/2]

template<typename T, int Size>
void blender::fixed_width_int::operator-= ( IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 448 of file BLI_fixed_width_int.hh.

References b.

◆ operator-=() [2/2]

template<typename T, int Size>
void blender::fixed_width_int::operator-= ( UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

Definition at line 443 of file BLI_fixed_width_int.hh.

References b.

◆ operator<() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator< ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator<() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator< ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator<=() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator<= ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator<=() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator<= ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator==() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator== ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

Definition at line 464 of file BLI_fixed_width_int.hh.

References b, and blender::fixed_width_int::IntF< T, S >::v.

◆ operator==() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator== ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

Definition at line 470 of file BLI_fixed_width_int.hh.

References b, and blender::fixed_width_int::UIntF< T, S >::v.

◆ operator>() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator> ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator>() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator> ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline

◆ operator>=() [1/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator>= ( const IntF< T, Size > & a,
const IntF< T, Size > & b )
inline

◆ operator>=() [2/2]

template<typename T, int Size>
bool blender::fixed_width_int::operator>= ( const UIntF< T, Size > & a,
const UIntF< T, Size > & b )
inline