TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Some utilities on integers. More...
Classes | |
struct | ts::int_max< INT > |
The meta-type ts::int_max selects the integer type with largest width and same signedness as another integer type. More... | |
struct | ts::make_signed< T > |
The meta-type ts::make_signed is a generalization of std::make_signed which works on floating point-types as well. More... | |
struct | ts::smaller_unsigned< BITS > |
Define the smaller unsigned integer type with at least a given number of bits. More... | |
struct | ts::static_power10< INT, POW > |
Static values of power of 10. More... | |
Namespaces | |
namespace | ts |
TSDuck namespace, containing all TSDuck classes and functions. | |
Concepts | |
concept | ts::int_enum |
A C++20 concept which requires a type to be an integer or an enumeration type. | |
Functions | |
template<typename INT > requires std::integral<INT> | |
INT | ts::abs (INT a) |
Absolute value of integer types, also working on unsigned types. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::add_overflow (INT a, INT b) platform_specific |
Check if an integer addition generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::add_overflow (INT a, INT b, INT res) |
Check if an integer addition generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
size_t | ts::BitSize (INT x) |
Get the size in bits of an integer value. | |
template<typename INT1 , typename INT2 > requires std::integral<INT1> && std::integral<INT2> | |
bool | ts::bound_check (INT2 x) |
Integer cross-type bound check. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::bounded_add (INT a, INT b) |
Perform a bounded addition without overflow. | |
template<typename INT1 , typename INT2 > requires std::integral<INT1> && std::integral<INT2> | |
INT1 | ts::bounded_cast (INT2 x) |
Bounded integer cast. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::bounded_sub (INT a, INT b) |
Perform a bounded subtraction without overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::debug_thow_neg_overflow (INT a) |
In debug mode, throw an exception if the negation (opposite sign) of an integer generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::debug_throw_add_overflow (INT a, INT b, INT res) |
In debug mode, throw an exception if an integer addition generates an overflow. | |
template<typename INT1 , typename INT2 > requires std::integral<INT1> && std::integral<INT2> | |
void | ts::debug_throw_bound_check (INT2 x) |
In debug mode, throw an exception if an integer value does not fall into the range of another integer type. | |
template<typename INT > requires std::integral<INT> | |
void | ts::debug_throw_div_zero (INT den) |
In debug mode, throw an exception if the denominator of an integer division is zero. | |
template<typename INT > requires std::integral<INT> | |
void | ts::debug_throw_mul_overflow (INT a, INT b, INT res) |
In debug mode, throw an exception if an integer multiplication generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::debug_throw_sub_overflow (INT a, INT b, INT res) |
In debug mode, throw an exception if an integer substraction generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::GCD (INT x, INT y) |
Compute a greatest common denominator (GCD). | |
template<typename INT > requires std::integral<INT> | |
bool | ts::is_negative (INT a) |
Check if an integer value is negative, optimized for signed or unsigned type. | |
size_t | ts::MaxDecimalWidth (size_t typeSize, size_t digitSeparatorSize=0) |
Compute the maximum width of the decimal representation of an integer type. | |
size_t | ts::MaxHexaWidth (size_t typeSize, size_t digitSeparatorSize=0) |
Compute the maximum width of the hexadecimal representation of an integer type. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::mul_overflow (INT a, INT b) platform_specific |
Check if an integer multiplication generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::mul_overflow (INT a, INT b, INT res) |
Check if an integer multiplication generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::neg_overflow (INT a) |
Check if the negation (opposite sign) of an integer generates an overflow. | |
uint64_t | ts::Power10 (size_t pow) |
Get a power of 10 using a fast lookup table. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::round_down (INT x, INT f) |
Round x down to previous multiple of a factor f. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::round_up (INT x, INT f) |
Round x up to next multiple of a factor f. | |
template<typename INT > requires std::integral<INT> | |
INT | ts::rounded_div (INT a, INT b) |
Integer division with rounding to closest value (instead of truncating). | |
template<typename INT > requires std::integral<INT> | |
void | ts::sign_reduce (INT &num, INT &den) |
Reduce the sign of an integer fraction. | |
template<typename INT > requires std::integral<INT> | |
const UChar * | ts::SignedDescription () |
Get the signed/unsigned qualifier of an integer type as a string. | |
template<typename INT > requires std::signed_integral<INT> | |
INT | ts::SignExtend (INT x, size_t bits) |
Perform a sign extension on any subset of a signed integer. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::sub_overflow (INT a, INT b) platform_specific |
Check if an integer substraction generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
bool | ts::sub_overflow (INT a, INT b, INT res) |
Check if an integer substraction generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::thow_neg_overflow (INT a) |
Throw an exception if the negation (opposite sign) of an integer generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::throw_add_overflow (INT a, INT b, INT res) |
Throw an exception if an integer addition generates an overflow. | |
template<typename INT1 , typename INT2 > requires std::integral<INT1> && std::integral<INT2> | |
void | ts::throw_bound_check (INT2 x) |
Throw an exception if an integer value does not fall into the range of another integer type. | |
template<typename INT > requires std::integral<INT> | |
void | ts::throw_div_zero (INT den) |
Throw an exception if the denominator of an integer division is zero. | |
template<typename INT > requires std::integral<INT> | |
void | ts::throw_mul_overflow (INT a, INT b, INT res) |
Throw an exception if an integer multiplication generates an overflow. | |
template<typename INT > requires std::integral<INT> | |
void | ts::throw_sub_overflow (INT a, INT b, INT res) |
Throw an exception if an integer substraction generates an overflow. | |
Variables | |
constexpr size_t | ts::MAX_POWER_10 = 19 |
Largest representable power of 10 in integer types. | |
Some utilities on integers.