deprecated-inlines.h File
C++ header file with inline implementations for the deprecated µTest++ definitions. More...
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | detail |
|
Internal implementation details for the µTest++ framework. More... | |
| namespace | math |
|
Internal mathematical utilities for the µTest++ testing framework. More... | |
| namespace | literals |
|
Deprecated user-defined literals of the test checks. More... | |
| namespace | operators |
|
Deprecated comparison and logical operators of the test checks. More... | |
Operators Index
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator and (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated logical && (and) operator. More... | |
template <class T> | |
| constexpr auto | operator not (T &&t) |
|
Deprecated logical ! (not) operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator or (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated logical || (or) operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator!= (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated non-equality operator. More... | |
| constexpr auto | operator""_b (const char *name, decltype(sizeof("")) size) |
|
Deprecated user-defined literal operator to create a named boolean constant. More... | |
template <char... Cs> | |
| constexpr auto | operator""_c () |
|
Deprecated user-defined literal operator to convert to char. More... | |
template <char... Cs> | |
| constexpr auto | operator""_d () |
|
Deprecated user-defined literal operator to convert to double. More... | |
template <char... Cs> | |
| constexpr auto | operator""_f () |
|
Deprecated user-defined literal operator to convert to float. More... | |
template <char... Cs> | |
| constexpr auto | operator""_i () |
|
Deprecated user-defined literal operator to convert to int. More... | |
template <char... Cs> | |
| constexpr auto | operator""_i16 () |
|
Deprecated user-defined literal operator to convert to int16_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_i32 () |
|
Deprecated user-defined literal operator to convert to int32_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_i64 () |
|
Deprecated user-defined literal operator to convert to int64_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_i8 () |
|
Deprecated user-defined literal operator to convert to int8_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_l () |
|
Deprecated user-defined literal operator to convert to long. More... | |
template <char... Cs> | |
| constexpr auto | operator""_ld () |
|
Deprecated user-defined literal operator to convert to long double. More... | |
template <char... Cs> | |
| constexpr auto | operator""_ll () |
|
Deprecated user-defined literal operator to convert to long long. More... | |
template <char... Cs> | |
| constexpr auto | operator""_s () |
|
Deprecated user-defined literal operator to convert to short. More... | |
template <char... Cs> | |
| constexpr auto | operator""_sc () |
|
Deprecated user-defined literal operator to convert to signed char. More... | |
template <char... Cs> | |
| constexpr auto | operator""_u () |
|
Deprecated user-defined literal operator to convert to unsigned. More... | |
template <char... Cs> | |
| constexpr auto | operator""_u16 () |
|
Deprecated user-defined literal operator to convert to uint16_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_u32 () |
|
Deprecated user-defined literal operator to convert to uint32_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_u64 () |
|
Deprecated user-defined literal operator to convert to uint64_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_u8 () |
|
Deprecated user-defined literal operator to convert to uint8_t. More... | |
template <char... Cs> | |
| constexpr auto | operator""_uc () |
|
Deprecated user-defined literal operator to convert to unsigned char. More... | |
template <char... Cs> | |
| constexpr auto | operator""_ul () |
|
Deprecated user-defined literal operator to convert to unsigned long. More... | |
template <char... Cs> | |
| constexpr auto | operator""_ull () |
|
Deprecated user-defined literal operator to convert to unsigned long long. More... | |
template <char... Cs> | |
| constexpr auto | operator""_us () |
|
Deprecated user-defined literal operator to convert to unsigned short. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator< (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated less than operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator<= (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated less than or equal operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator== (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated equality operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator> (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated greater than operator. More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | operator>= (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated greater than or equal operator. More... | |
Functions Index
template <class T, class Value_T> | |
| constexpr T | count_decimals (Value_T value) |
|
Computes the number of decimal places of a value, with a precision of about seven digits. More... | |
template <bool Fraction, char... Cs> | |
| std::size_t | count_literal_digits (void) |
|
Counts the decimal digits of a floating-point literal, before or after the decimal point. More... | |
template <class Value_T> | |
| constexpr Value_T | decimal_epsilon (Value_T value) |
|
Computes the default comparison tolerance of a floating-point value, one unit of its last decimal. More... | |
template <class T, char... Cs> | |
| T | den (void) |
|
Computes the decimal part of a number represented as an array of characters. More... | |
template <class T, char... Cs> | |
| T | den_size (void) |
|
Counts the decimal places of a number represented as an array of characters. More... | |
template <class T, char... Cs> | |
| unsigned long long | integer_magnitude (void) |
|
Computes the value of an integer literal of type T, before any negation. More... | |
template <class T, char... Cs> | |
| constexpr auto | integral_literal (void) |
|
Creates the compile-time constant of an integer literal. More... | |
template <class T, char... Cs> | |
| T | num (void) |
|
Computes the integral part of a decimal floating-point number represented as an array of characters. More... | |
template <char... Cs> | |
| integer_literal | parse_integer_literal (void) |
|
Parses the characters of an integer literal. More... | |
template <class T, class Exp_T> | |
| constexpr T | pow (const T base, const Exp_T exp) noexcept |
|
Generic exponentiation function to compute the power of a base raised to an exponent. More... | |
Deprecated Functions Index
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | _and (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated generic logical and operation, the v5.0.1 name of all_of(). More... | |
template <class Expr_T> | |
| constexpr auto | _not (Expr_T &&expr) |
|
Deprecated generic logical not operation, the v5.0.1 name of negate(). More... | |
template <class Lhs_T, class Rhs_T> | |
| constexpr auto | _or (Lhs_T &&lhs, Rhs_T &&rhs) |
|
Deprecated generic logical (inclusive) or operation, the v5.0.1 name of any_of(). More... | |
template <class T> | |
| constexpr auto | approx (T value, std::type_identity_t< T > epsilon) noexcept -> detail::value< T > |
|
Deprecated wrapping of a floating-point value with an explicit comparison tolerance. More... | |
template <class T> | |
| constexpr T & | mut (const T &t) noexcept |
|
Deprecated generic mutator to remove const qualification from a reference. More... | |
Description
C++ header file with inline implementations for the deprecated µTest++ definitions.
This header provides the inline implementations for the deprecated definitions declared in deprecated.h: the v5.0.1 names of the logical functions (_not, _and, and _or), which forward to negate(), all_of(), and any_of(), mut(), the overloaded operators, the user-defined literals, and approx (value, epsilon), and the members of the detail::timestamp class.
The constructor of detail::timestamp that reads the system clock is defined in src/deprecated.cpp, with detail::read_clock(), the clock access used by detail::stopwatch.
All definitions reside within the micro_os_plus::micro_test_plus namespace.
This file is included by deprecated.h; the applications include micro-os-plus/micro-test-plus.h, not this file.
Functions
count_decimals()
| nodiscard constexpr |
Computes the number of decimal places of a value, with a precision of about seven digits.
- Template Parameters
-
T The integral type for the result.
Value_T The type of the input value, a floating-point type.
- Parameters
-
value The value whose decimal precision is to be determined; it may be negative, infinite, or a NaN.
- Returns
The number of decimal places, as a value of type T, at least one, or zero for a zero value; the leading zeros of a value below one are counted; it is limited by the magnitude from which Value_T represents only integers.
This function template determines the number of decimal (fractional) digits present in a floating-point value, with a precision of about seven digits. Being constexpr, it can also be evaluated at compile time.
The function repeatedly multiplies the absolute value by ten, incrementing a counter until the distance to the nearest integer is at most a defined precision threshold (1e-7). Using the distance to the nearest integer, not the fractional part, prevents the rounding noise of a value just below an integer (e.g. 2674.9999999999995) from being taken as more decimals.
The nearest integer is never zero: while the scaled value is below one, its distance to one is used, so that the leading zeros of a small value are counted as decimals, as in its notation (12 for 1e-12), instead of the count stopping as soon as the scaled value is below the threshold. A zero value has no significant digit, and the result is zero.
The loop also stops when the value reaches the magnitude from which the type can represent only integers (2^23 for float, 2^52 for double), limited to 2^63 so that the conversion to unsigned long long is always defined. This bounds the number of steps for large values, infinities, and NaNs, for which the result is one; for small values, the number of steps is bounded by the decimal exponent of the smallest value of the type.
Definition at line 258 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::abs, micro_os_plus::micro_test_plus::detail::math::count_decimals and micro_os_plus::micro_test_plus::detail::math::min_value.
Referenced by micro_os_plus::micro_test_plus::detail::math::count_decimals and micro_os_plus::micro_test_plus::detail::math::decimal_epsilon.
count_literal_digits()
| nodiscard |
Counts the decimal digits of a floating-point literal, before or after the decimal point.
The digit separators (') are not counted.
- Template Parameters
-
Fraction true to count the digits after the decimal point, false to count those before it.
Cs The characters of the literal.
- Parameters
None.
- Returns
The number of digits.
Walks the characters once, counting the decimal digits before the first decimal point (Fraction false) or after it (Fraction true); the digit separators are skipped.
Definition at line 101 of file deprecated-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::math::count_literal_digits.
Referenced by micro_os_plus::micro_test_plus::detail::math::count_literal_digits, micro_os_plus::micro_test_plus::detail::math::den, micro_os_plus::micro_test_plus::detail::math::den_size and micro_os_plus::micro_test_plus::detail::math::num.
decimal_epsilon()
| nodiscard constexpr |
Computes the default comparison tolerance of a floating-point value, one unit of its last decimal.
- Template Parameters
-
Value_T The type of the value, a floating-point type.
- Parameters
-
value The value whose tolerance is to be determined; it may be negative, infinite, or a NaN.
- Returns
Ten raised to minus the number of decimal places returned by count_decimals() (0.01 for 1.25, 1e-12 for 1e-12), or zero, which means an exact comparison, for a zero value and for a value whose tolerance would be below the range of Value_T.
The number of decimal places is computed by count_decimals(), and the tolerance is one divided by ten raised to that number, as for the floating-point literals, which use the decimals written.
A zero value has no decimals, and gets a zero tolerance, so that it is compared exactly; a tolerance of one unit of an arbitrary decimal would make the zero equal to unrelated small values. A zero tolerance is also returned when ten raised to the number of decimals would exceed the range of Value_T (values below about 1e-308 for double), instead of computing an infinite power.
Definition at line 326 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::count_decimals, micro_os_plus::micro_test_plus::detail::math::decimal_epsilon and micro_os_plus::micro_test_plus::detail::math::pow.
Referenced by micro_os_plus::micro_test_plus::detail::math::decimal_epsilon.
den()
| nodiscard |
Computes the decimal part of a number represented as an array of characters.
- Template Parameters
-
T The target integral type for the result.
Cs The character pack representing the numeric value; it must contain a decimal point.
- Parameters
None.
- Returns
The digits after the decimal point, as an integral value of type T (e.g. 25 for 1.25), to be divided by ten raised to the power returned by den_size().
This function template performs compile-time extraction of the decimal (fractional) part from a sequence of characters, typically provided as a template parameter pack.
The function expects the character sequence to represent a numeric value, where all characters are either digits, a dot (.), or an apostrophe ('). Parsing begins after the first dot, accumulating the decimal digits as an integer value and skipping the digit separators (e.g. 1.25 yields 25), so that den() / 10^den_size() gives the fraction. If the result could exceed T, the compilation fails with an explicit message.
Definition at line 177 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::count_literal_digits and micro_os_plus::micro_test_plus::detail::math::den.
Referenced by micro_os_plus::micro_test_plus::detail::math::den, micro_os_plus::micro_test_plus::literals::operator""_d, micro_os_plus::micro_test_plus::literals::operator""_f and micro_os_plus::micro_test_plus::literals::operator""_ld.
den_size()
| nodiscard |
Counts the decimal places of a number represented as an array of characters.
- Template Parameters
-
T The integral type for the result.
Cs The character pack representing the numeric value; it must contain a decimal point.
- Parameters
None.
- Returns
The number of decimal places (e.g. 2 for 1.25), as a value of type T; it is the scale of the value returned by den().
This function template determines, at compile time, the number of decimal (fractional) digits present in a numeric value represented by a character sequence, typically provided as a template parameter pack.
The function expects the character sequence to represent a numeric value, where all characters are either digits, a dot (.), or an apostrophe ('). It returns the number of digits that follow the first dot (the digit separators are not counted; e.g. 2 for 1.25), which is the scale of the value returned by den().
Definition at line 220 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::count_literal_digits and micro_os_plus::micro_test_plus::detail::math::den_size.
Referenced by micro_os_plus::micro_test_plus::detail::math::den_size, micro_os_plus::micro_test_plus::literals::operator""_d, micro_os_plus::micro_test_plus::literals::operator""_f and micro_os_plus::micro_test_plus::literals::operator""_ld.
integer_magnitude()
| nodiscard |
Computes the value of an integer literal of type T, before any negation.
- Template Parameters
-
T The integral type of the literal.
Cs The characters of the literal, as received by a literal operator template.
- Parameters
None.
- Returns
The value of the literal, up to max() of T, or, for the signed types, up to max () + 1, the absolute value of the minimum.
The literal must be an integer literal, in any of the C++ forms (decimal, hexadecimal, binary, or octal, with digit separators), and its value must fit in T; otherwise the compilation fails with an explicit message.
Negative values are obtained with the unary minus, so the literal itself is never negative. For the signed types, the limit is the absolute value of the minimum, max () + 1, so that the minimum can be written (e.g. -128_i8); the caller allows this magnitude only when it is negated.
When a check fails, zero is returned, so that the callers report no further errors.
Definition at line 448 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::integer_magnitude, micro_os_plus::micro_test_plus::detail::math::integer_literal::is_integer, micro_os_plus::micro_test_plus::detail::math::integer_literal::is_too_large, micro_os_plus::micro_test_plus::detail::math::parse_integer_literal and micro_os_plus::micro_test_plus::detail::math::integer_literal::value.
Referenced by micro_os_plus::micro_test_plus::detail::math::integer_magnitude and micro_os_plus::micro_test_plus::detail::integral_literal.
integral_literal()
| nodiscard constexpr |
Creates the compile-time constant of an integer literal.
- Template Parameters
-
T The integral type of the literal.
Cs The characters of the literal, as received by a literal operator template.
Used by the integer literal operators (_i, _u8, etc.).
- Parameters
None.
- Returns
An integral_constant with the value of the literal, or, when the value is the absolute value of the minimum of a signed T, an integral_min_magnitude<T>, valid only when negated.
The value is checked by math::integer_magnitude(), which accepts, for the signed types, the absolute value of the minimum; this value does not fit in T, so it is represented by integral_min_magnitude<T>.
Definition at line 581 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::integral_constant< N >::integral_constant, micro_os_plus::micro_test_plus::detail::math::integer_magnitude and micro_os_plus::micro_test_plus::detail::integral_literal.
Referenced by micro_os_plus::micro_test_plus::detail::integral_literal, micro_os_plus::micro_test_plus::literals::operator""_c, micro_os_plus::micro_test_plus::literals::operator""_i, micro_os_plus::micro_test_plus::literals::operator""_i16, micro_os_plus::micro_test_plus::literals::operator""_i32, micro_os_plus::micro_test_plus::literals::operator""_i64, micro_os_plus::micro_test_plus::literals::operator""_i8, micro_os_plus::micro_test_plus::literals::operator""_l, micro_os_plus::micro_test_plus::literals::operator""_ll, micro_os_plus::micro_test_plus::literals::operator""_s, micro_os_plus::micro_test_plus::literals::operator""_sc, micro_os_plus::micro_test_plus::literals::operator""_u, micro_os_plus::micro_test_plus::literals::operator""_u16, micro_os_plus::micro_test_plus::literals::operator""_u32, micro_os_plus::micro_test_plus::literals::operator""_u64, micro_os_plus::micro_test_plus::literals::operator""_u8, micro_os_plus::micro_test_plus::literals::operator""_uc, micro_os_plus::micro_test_plus::literals::operator""_ul, micro_os_plus::micro_test_plus::literals::operator""_ull and micro_os_plus::micro_test_plus::literals::operator""_us.
num()
| nodiscard |
Computes the integral part of a decimal floating-point number represented as an array of characters.
Used by the floating-point literal operators; the integer literals use integer_magnitude(), which also accepts the C++ prefixes and checks the range.
- Template Parameters
-
T The target integral type for the result.
Cs The character pack representing the numeric value.
- Parameters
None.
- Returns
The parsed integral value of type T.
This function template performs compile-time parsing of a numeric value from a sequence of characters, typically provided as a template parameter pack.
The characters must be decimal digits, a dot (.), or digit separators ('), which are skipped; otherwise (e.g. an exponent) the compilation fails with an explicit message, as it does if the integral part has more digits than T can always hold. Parsing stops at the first dot, allowing the function to extract only the integral part of the number.
Definition at line 134 of file deprecated-inlines.h.
References micro_os_plus::micro_test_plus::detail::math::count_literal_digits and micro_os_plus::micro_test_plus::detail::math::num.
Referenced by micro_os_plus::micro_test_plus::detail::math::num, micro_os_plus::micro_test_plus::literals::operator""_d, micro_os_plus::micro_test_plus::literals::operator""_f and micro_os_plus::micro_test_plus::literals::operator""_ld.
parse_integer_literal()
| nodiscard |
Parses the characters of an integer literal.
- Template Parameters
-
Cs The characters of the literal, as received by a literal operator template.
- Parameters
None.
- Returns
The value, and whether the characters form an integer literal and whether its value fits in unsigned long long.
The characters are those of a valid C++ literal, already checked by the compiler (digits valid for the base, digit separators in valid positions). The base is given by the prefix: 0x or 0X for hexadecimal, 0b or 0B for binary, a leading 0 for octal, and none for decimal. The digit separators (') are skipped.
Any other character (a decimal point, an exponent, or a digit not valid for the base, as in the floating-point literal 09.5) marks the literal as not an integer. The value is accumulated in unsigned long long, and the accumulation stops if it would overflow.
Definition at line 354 of file deprecated-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::math::parse_integer_literal.
Referenced by micro_os_plus::micro_test_plus::detail::math::integer_magnitude and micro_os_plus::micro_test_plus::detail::math::parse_integer_literal.
pow()
| nodiscard constexpr noexcept |
Generic exponentiation function to compute the power of a base raised to an exponent.
- Template Parameters
-
T The type of the base value. Must support multiplication assignment and construction from an integer.
Exp_T The type of the exponent. Must be default-constructible (to zero), and support the < and prefix ++ operators.
- Parameters
-
base The base value to be raised to the power of exp.
exp The exponent value.
- Returns
The result of raising base to the power of exp.
This function template provides a constexpr implementation for raising a base value to a given exponent, supporting any types that allow multiplication.
The function starts from one and multiplies the result by the base exp times. If the exponent is zero (or negative), the function returns one (the multiplicative identity for the type).
Definition at line 85 of file deprecated-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::math::pow.
Referenced by micro_os_plus::micro_test_plus::detail::math::decimal_epsilon and micro_os_plus::micro_test_plus::detail::math::pow.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.