![]() |
C++ Library Extensions 2022.12.09
To help learn modern C++ programming
|
Defines safe type operation. More...
Namespaces | |
namespace | hidden |
Functions | |
template<typename Type > | |
types::enable_if_integral_t< Type, int > | count_set_bits (Type bits) |
Counts set bits. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | to_bits (Type bits) |
Returns binary bit pattern. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | to_hex (Type v) |
Returns hexidecimal representation. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | to_dec (Type v) |
Returns decimal representation. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, int > | field_width (Type v) |
Returns' field width. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, int > | numeric_width () |
Return's maximum numeric field width. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | to_dec_width (Type v) |
Returns decimal field width. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | numeric_base (Type v) |
Displays how integral types are represented. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, std::string > | numeric_type_info (Type) |
Displays integral type's numerical information. More... | |
template<typename = void> | |
void | integral_type_info () |
Displays all integral types' representation. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type, void > | twos_complement (Type c) |
Displays Twos complement. More... | |
template<typename Type > | |
types::enable_if_signed_integral_t< Type > | safe_add (Type a, Type b) |
Safe addition of the signed integral types. More... | |
template<typename Type > | |
types::enable_if_signed_integral_t< Type > | safe_sub (Type a, Type b) |
Safe subtraction of signed integral types. More... | |
template<typename Type > | |
types::enable_if_unsigned_integral_t< Type > | safe_add (Type a, Type b) |
Safe addition of the unsigned integral types. More... | |
template<typename Type > | |
types::enable_if_unsigned_integral_t< Type > | safe_sub (Type a, Type b) |
Safe subtraction of unsigned integral types. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type > | safe_mul (Type a, Type b) |
Safe multiplication of integral types. More... | |
template<typename Type > | |
types::enable_if_integral_t< Type > | safe_div (Type a, Type b) |
Safe division of integral types. More... | |
template<typename Type > | |
types::enable_if_real_number_t< Type > | safe_add (Type a, Type b) |
template<typename Type > | |
types::enable_if_real_number_t< Type > | safe_sub (Type a, Type b) |
template<typename Type > | |
types::enable_if_real_number_t< Type > | safe_mul (Type a, Type b) |
template<typename Type > | |
types::enable_if_real_number_t< Type > | safe_div (Type a, Type b) |
Variables | |
template<typename Type > | |
constexpr Type | limits_max |
Upperbound number the Type can represent. More... | |
template<typename Type > | |
constexpr Type | limits_min |
Lowerbound number the Type can represent. More... | |
template<typename T > | |
constexpr int | sizeof_bits = sizeof(T) * 8 |
Returns bit count of type T. More... | |
template<typename T > | |
constexpr auto | high_bit_mask |
Return's bit mask for the highest bit. More... | |
Defines safe type operation.
types::enable_if_integral_t< Type, int > tpf::safe_type::count_set_bits | ( | Type | bits | ) |
Counts set bits.
Type |
bits |
Definition at line 120 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, int > tpf::safe_type::field_width | ( | Type | v | ) |
Returns' field width.
Type |
v |
Definition at line 241 of file tpf_safe_type.hpp.
void tpf::safe_type::integral_type_info | ( | ) |
Displays all integral types' representation.
Definition at line 338 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::numeric_base | ( | Type | v | ) |
Displays how integral types are represented.
Type |
v |
Definition at line 301 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::numeric_type_info | ( | Type | ) |
Displays integral type's numerical information.
Type |
Definition at line 318 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, int > tpf::safe_type::numeric_width | ( | ) |
Return's maximum numeric field width.
Type |
Definition at line 261 of file tpf_safe_type.hpp.
types::enable_if_signed_integral_t< Type > tpf::safe_type::safe_add | ( | Type | a, |
Type | b | ||
) |
Safe addition of the signed integral types.
Type |
a | |
b |
Definition at line 387 of file tpf_safe_type.hpp.
types::enable_if_unsigned_integral_t< Type > tpf::safe_type::safe_add | ( | Type | a, |
Type | b | ||
) |
Safe addition of the unsigned integral types.
Type |
a | |
b |
Definition at line 455 of file tpf_safe_type.hpp.
types::enable_if_real_number_t< Type > tpf::safe_type::safe_add | ( | Type | a, |
Type | b | ||
) |
Definition at line 554 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type > tpf::safe_type::safe_div | ( | Type | a, |
Type | b | ||
) |
Safe division of integral types.
Type |
a | |
b |
Definition at line 538 of file tpf_safe_type.hpp.
types::enable_if_real_number_t< Type > tpf::safe_type::safe_div | ( | Type | a, |
Type | b | ||
) |
Definition at line 605 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type > tpf::safe_type::safe_mul | ( | Type | a, |
Type | b | ||
) |
Safe multiplication of integral types.
Type |
a | |
b |
Definition at line 512 of file tpf_safe_type.hpp.
types::enable_if_real_number_t< Type > tpf::safe_type::safe_mul | ( | Type | a, |
Type | b | ||
) |
Definition at line 588 of file tpf_safe_type.hpp.
types::enable_if_signed_integral_t< Type > tpf::safe_type::safe_sub | ( | Type | a, |
Type | b | ||
) |
Safe subtraction of signed integral types.
Type |
a | |
b |
Definition at line 439 of file tpf_safe_type.hpp.
types::enable_if_unsigned_integral_t< Type > tpf::safe_type::safe_sub | ( | Type | a, |
Type | b | ||
) |
Safe subtraction of unsigned integral types.
Type |
a | |
b |
Definition at line 484 of file tpf_safe_type.hpp.
types::enable_if_real_number_t< Type > tpf::safe_type::safe_sub | ( | Type | a, |
Type | b | ||
) |
Definition at line 571 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::to_bits | ( | Type | bits | ) |
Returns binary bit pattern.
Type |
bits |
Definition at line 141 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::to_dec | ( | Type | v | ) |
Returns decimal representation.
Type |
v |
Definition at line 220 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::to_dec_width | ( | Type | v | ) |
Returns decimal field width.
Type |
v |
Definition at line 278 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, std::string > tpf::safe_type::to_hex | ( | Type | v | ) |
Returns hexidecimal representation.
Type |
v |
Definition at line 167 of file tpf_safe_type.hpp.
types::enable_if_integral_t< Type, void > tpf::safe_type::twos_complement | ( | Type | c | ) |
Displays Twos complement.
Type |
c |
Definition at line 363 of file tpf_safe_type.hpp.
|
constexpr |
Return's bit mask for the highest bit.
T |
Definition at line 108 of file tpf_safe_type.hpp.
|
constexpr |
Upperbound number the Type can represent.
Type |
Definition at line 53 of file tpf_safe_type.hpp.
|
constexpr |
Lowerbound number the Type can represent.
Type |
Definition at line 61 of file tpf_safe_type.hpp.
|
constexpr |
Returns bit count of type T.
T | for querying bit count |
Definition at line 100 of file tpf_safe_type.hpp.