Blender V4.3
blender::fixed_width_int Namespace Reference

Classes

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

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 123 of file BLI_fixed_width_int.hh.

◆ Int128

◆ Int128_16

◆ Int128_32

◆ Int128_64

◆ Int128_8

Definition at line 143 of file BLI_fixed_width_int.hh.

◆ Int256

◆ Int256_16

◆ Int256_32

◆ Int256_64

◆ Int256_8

Definition at line 148 of file BLI_fixed_width_int.hh.

◆ Int64_16

◆ Int64_32

◆ Int64_8

Definition at line 129 of file BLI_fixed_width_int.hh.

◆ UInt128

◆ UInt128_16

◆ UInt128_32

◆ UInt128_64

◆ UInt128_8

◆ UInt256

◆ UInt256_16

◆ UInt256_32

◆ UInt256_64

◆ UInt256_8

◆ UInt64_16

◆ UInt64_32

◆ UInt64_8

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

◆ 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 279 of file BLI_fixed_width_int.hh.

References b, 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 296 of file BLI_fixed_width_int.hh.

References b, 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 310 of file BLI_fixed_width_int.hh.

References b, 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 378 of file BLI_fixed_width_int.hh.

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

Definition at line 390 of file BLI_fixed_width_int.hh.

References result, and blender::unroll().

◆ is_zero() [2/2]

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

Definition at line 383 of file BLI_fixed_width_int.hh.

References result, and blender::unroll().

◆ 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 470 of file BLI_fixed_width_int.hh.

References b.

◆ 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 476 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

Definition at line 398 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

Definition at line 367 of file BLI_fixed_width_int.hh.

References b, generic_unsigned_mul(), and result.

◆ 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 452 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 447 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

Definition at line 343 of file BLI_fixed_width_int.hh.

References b, generic_add(), and result.

◆ 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

Definition at line 335 of file BLI_fixed_width_int.hh.

References b, generic_add(), and result.

◆ 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 432 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 427 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 418 of file BLI_fixed_width_int.hh.

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

◆ 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

Definition at line 359 of file BLI_fixed_width_int.hh.

References b, generic_sub(), and result.

◆ 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

Definition at line 351 of file BLI_fixed_width_int.hh.

References b, generic_sub(), and result.

◆ 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 442 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 437 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

Definition at line 496 of file BLI_fixed_width_int.hh.

References b, compare_reversed_order(), and is_negative().

◆ 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 540 of file BLI_fixed_width_int.hh.

References b, and compare_reversed_order().

◆ 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 507 of file BLI_fixed_width_int.hh.

References b, compare_reversed_order(), and is_negative().

◆ 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 546 of file BLI_fixed_width_int.hh.

References b, and compare_reversed_order().

◆ 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 458 of file BLI_fixed_width_int.hh.

References b.

◆ 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 464 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

Definition at line 518 of file BLI_fixed_width_int.hh.

References b, compare_reversed_order(), and is_negative().

◆ 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 552 of file BLI_fixed_width_int.hh.

References b, and compare_reversed_order().

◆ 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 529 of file BLI_fixed_width_int.hh.

References b, compare_reversed_order(), and is_negative().

◆ 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 558 of file BLI_fixed_width_int.hh.

References b, and compare_reversed_order().