Skip to main content

deprecated-inlines.h File

C++ header file with inline implementations for the deprecated µTest++ definitions. More...

Namespaces Index​

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespacedetail

Internal implementation details for the µTest++ framework. More...

namespacemath

Internal mathematical utilities for the µTest++ testing framework. More...

namespaceliterals

Deprecated user-defined literals of the test checks. More...

namespaceoperators

Deprecated comparison and logical operators of the test checks. More...

Operators Index​

template <class Lhs_T, class Rhs_T>
constexpr autooperator and (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated logical && (and) operator. More...

template <class T>
constexpr autooperator not (T &&t)

Deprecated logical ! (not) operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator or (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated logical || (or) operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator!= (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated non-equality operator. More...

constexpr autooperator""_b (const char *name, decltype(sizeof("")) size)

Deprecated user-defined literal operator to create a named boolean constant. More...

template <char... Cs>
constexpr autooperator""_c ()

Deprecated user-defined literal operator to convert to char. More...

template <char... Cs>
constexpr autooperator""_d ()

Deprecated user-defined literal operator to convert to double. More...

template <char... Cs>
constexpr autooperator""_f ()

Deprecated user-defined literal operator to convert to float. More...

template <char... Cs>
constexpr autooperator""_i ()

Deprecated user-defined literal operator to convert to int. More...

template <char... Cs>
constexpr autooperator""_i16 ()

Deprecated user-defined literal operator to convert to int16_t. More...

template <char... Cs>
constexpr autooperator""_i32 ()

Deprecated user-defined literal operator to convert to int32_t. More...

template <char... Cs>
constexpr autooperator""_i64 ()

Deprecated user-defined literal operator to convert to int64_t. More...

template <char... Cs>
constexpr autooperator""_i8 ()

Deprecated user-defined literal operator to convert to int8_t. More...

template <char... Cs>
constexpr autooperator""_l ()

Deprecated user-defined literal operator to convert to long. More...

template <char... Cs>
constexpr autooperator""_ld ()

Deprecated user-defined literal operator to convert to long double. More...

template <char... Cs>
constexpr autooperator""_ll ()

Deprecated user-defined literal operator to convert to long long. More...

template <char... Cs>
constexpr autooperator""_s ()

Deprecated user-defined literal operator to convert to short. More...

template <char... Cs>
constexpr autooperator""_sc ()

Deprecated user-defined literal operator to convert to signed char. More...

template <char... Cs>
constexpr autooperator""_u ()

Deprecated user-defined literal operator to convert to unsigned. More...

template <char... Cs>
constexpr autooperator""_u16 ()

Deprecated user-defined literal operator to convert to uint16_t. More...

template <char... Cs>
constexpr autooperator""_u32 ()

Deprecated user-defined literal operator to convert to uint32_t. More...

template <char... Cs>
constexpr autooperator""_u64 ()

Deprecated user-defined literal operator to convert to uint64_t. More...

template <char... Cs>
constexpr autooperator""_u8 ()

Deprecated user-defined literal operator to convert to uint8_t. More...

template <char... Cs>
constexpr autooperator""_uc ()

Deprecated user-defined literal operator to convert to unsigned char. More...

template <char... Cs>
constexpr autooperator""_ul ()

Deprecated user-defined literal operator to convert to unsigned long. More...

template <char... Cs>
constexpr autooperator""_ull ()

Deprecated user-defined literal operator to convert to unsigned long long. More...

template <char... Cs>
constexpr autooperator""_us ()

Deprecated user-defined literal operator to convert to unsigned short. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator< (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated less than operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator<= (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated less than or equal operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator== (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated equality operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator> (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated greater than operator. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator>= (Lhs_T &&lhs, Rhs_T &&rhs)

Deprecated greater than or equal operator. More...

Functions Index​

template <class T, class Value_T>
constexpr Tcount_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_tcount_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_Tdecimal_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>
Tden (void)

Computes the decimal part of a number represented as an array of characters. More...

template <class T, char... Cs>
Tden_size (void)

Counts the decimal places of a number represented as an array of characters. More...

template <class T, char... Cs>
unsigned long longinteger_magnitude (void)

Computes the value of an integer literal of type T, before any negation. More...

template <class T, char... Cs>
constexpr autointegral_literal (void)

Creates the compile-time constant of an integer literal. More...

template <class T, char... Cs>
Tnum (void)

Computes the integral part of a decimal floating-point number represented as an array of characters. More...

template <char... Cs>
integer_literalparse_integer_literal (void)

Parses the characters of an integer literal. More...

template <class T, class Exp_T>
constexpr Tpow (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()​

template <class T, class Value_T>
T micro_os_plus::micro_test_plus::detail::math::count_decimals (Value_T value)
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.

258 count_decimals (Value_T value) -> T
259 {
260 constexpr auto precision = Value_T (1e-7);
261 // From this magnitude upwards all values are integers.
262 constexpr auto integral_limit
263 = min_value (Value_T (1) / std::numeric_limits<Value_T>::epsilon (),
264 Value_T (1ULL << 63));
265
266 value = abs (value);
267
268#if defined(__GNUC__)
269#pragma GCC diagnostic push
270#pragma GCC diagnostic ignored "-Wfloat-equal"
271#endif // defined(__GNUC__)
272 if (value == Value_T (0))
273 {
274 // A zero has no decimals.
275 return T{};
276 }
277#if defined(__GNUC__)
278#pragma GCC diagnostic pop
279#endif // defined(__GNUC__)
280
281 T result{};
282 for (;;)
283 {
284 value *= 10;
285 ++result;
286
287 // Also true for infinities and NaNs.
288 if (not(value < integral_limit))
289 {
290 break;
291 }
292
293 const auto fraction = value
294 - static_cast<Value_T> (
295 static_cast<unsigned long long> (value));
296 // Below one, the distance is to one, not to zero, so that the
297 // leading zeros of a small value are counted.
298 const auto distance
299 = (value < Value_T (1))
300 ? Value_T (1) - fraction
301 : min_value (fraction, Value_T (1) - fraction);
302 if (distance <= precision)
303 {
304 break;
305 }
306 }
307
308 return result;
309 }

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()​

template <bool Fraction, char... Cs>
std::size_t micro_os_plus::micro_test_plus::detail::math::count_literal_digits (void)
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.

101 count_literal_digits (void) -> std::size_t
102 {
103 std::size_t count = 0;
104 bool is_fraction = false;
105 for (const char c : { Cs... })
106 {
107 if (c == '.')
108 {
109 is_fraction = true;
110 }
111 else if (c >= '0' and c <= '9' and is_fraction == Fraction)
112 {
113 ++count;
114 }
115 }
116 return count;
117 }

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()​

template <class Value_T>
Value_T micro_os_plus::micro_test_plus::detail::math::decimal_epsilon (Value_T value)
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.

326 decimal_epsilon (Value_T value) -> Value_T
327 {
328 const auto decimals = count_decimals<unsigned long long> (value);
329 if (decimals == 0
330 or decimals > static_cast<unsigned long long> (
331 std::numeric_limits<Value_T>::max_exponent10))
332 {
333 return Value_T{};
334 }
335 return Value_T (1) / pow (Value_T (10), decimals);
336 }

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()​

template <class T, char... Cs>
T micro_os_plus::micro_test_plus::detail::math::den (void)
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.

177 den (void) -> T
178 {
179 static_assert ((... || (Cs == '.')),
180 "den(): no decimal point in literal");
181 // The result has as many digits as the decimals, and it must fit in
182 // `T`.
183 static_assert (
184 count_literal_digits<true, Cs...> ()
185 <= static_cast<std::size_t> (std::numeric_limits<T>::digits10),
186 "µTest++: the floating-point literal has too many "
187 "decimals");
188 T result{};
189 bool is_fraction = false;
190 for (const char c : { Cs... })
191 {
192 if (c == '.')
193 {
194 is_fraction = true;
195 }
196 else if (is_fraction and c >= '0' and c <= '9')
197 {
198 // The digit separators are skipped.
199 result = static_cast<T> (result * static_cast<T> (10)
200 + static_cast<T> (c - '0'));
201 }
202 }
203 return result;
204 }

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()​

template <class T, char... Cs>
T micro_os_plus::micro_test_plus::detail::math::den_size (void)
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.

220 den_size (void) -> T
221 {
222 static_assert ((... || (Cs == '.')),
223 "den_size(): no decimal point in literal");
224 return static_cast<T> (count_literal_digits<true, Cs...> ());
225 }

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()​

template <class T, char... Cs>
unsigned long long micro_os_plus::micro_test_plus::detail::math::integer_magnitude (void)
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.

448 integer_magnitude (void) -> unsigned long long
449 {
450 constexpr integer_literal literal = parse_integer_literal<Cs...> ();
451 constexpr unsigned long long max_magnitude
452 = static_cast<unsigned long long> (std::numeric_limits<T>::max ())
453 + (std::numeric_limits<T>::is_signed ? 1u : 0u);
454 constexpr bool fits = literal.is_integer && !literal.is_too_large
455 && literal.value <= max_magnitude;
456
457 static_assert (literal.is_integer,
458 "µTest++: an integer literal must not have a decimal "
459 "point or an exponent");
460 static_assert (!literal.is_integer || !literal.is_too_large,
461 "µTest++: the integer literal is too large");
462 static_assert (!literal.is_integer || literal.is_too_large || fits,
463 "µTest++: the integer literal value does not fit in the "
464 "type of the literal");
465
466 return fits ? literal.value : 0;
467 }

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()​

template <class T, char... Cs>
auto micro_os_plus::micro_test_plus::detail::integral_literal (void)
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.

582 {
583 constexpr unsigned long long magnitude
584 = math::integer_magnitude<T, Cs...> ();
585
586 if constexpr (magnitude > static_cast<unsigned long long> (
587 std::numeric_limits<T>::max ()))
588 {
590 }
591 else
592 {
593 return integral_constant<static_cast<T> (magnitude)>{};
594 }
595 }

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()​

template <class T, char... Cs>
T micro_os_plus::micro_test_plus::detail::math::num (void)
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.

134 num (void) -> T
135 {
136 static_assert (
137 ((Cs == '.' or Cs == '\'' or (Cs >= '0' and Cs <= '9')) and ...),
138 "µTest++: a floating-point literal must be written with decimal "
139 "digits and a decimal point, without an exponent");
140 static_assert (
141 count_literal_digits<false, Cs...> ()
142 <= static_cast<std::size_t> (std::numeric_limits<T>::digits10),
143 "µTest++: the floating-point literal has too many "
144 "digits before the decimal point");
145 T result{};
146 for (const char c : { Cs... })
147 {
148 if (c == '.')
149 {
150 break;
151 }
152 if (c >= '0' and c <= '9')
153 {
154 result = static_cast<T> (result * static_cast<T> (10)
155 + static_cast<T> (c - '0'));
156 }
157 }
158 return result;
159 }

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()​

template <char... Cs>
integer_literal micro_os_plus::micro_test_plus::detail::math::parse_integer_literal (void)
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.

355 {
356 constexpr std::array<char, sizeof...(Cs)> cs{ Cs... };
357 constexpr unsigned long long max_value
358 = std::numeric_limits<unsigned long long>::max ();
359
360 integer_literal result{ 0, true, false };
361
362 unsigned long long base = 10;
363 std::size_t i = 0;
364 if (cs.size () > 1 && cs[0] == '0')
365 {
366 if (cs[1] == 'x' || cs[1] == 'X')
367 {
368 base = 16;
369 i = 2;
370 }
371 else if (cs[1] == 'b' || cs[1] == 'B')
372 {
373 base = 2;
374 i = 2;
375 }
376 else
377 {
378 base = 8;
379 i = 1;
380 }
381 }
382
383 for (; i < cs.size (); ++i)
384 {
385 const char c = cs[i];
386 if (c == '\'')
387 {
388 continue;
389 }
390
391 unsigned long long digit = 0;
392 if (c >= '0' && c <= '9')
393 {
394 digit = static_cast<unsigned long long> (c - '0');
395 }
396 else if (base == 16 && c >= 'a' && c <= 'f')
397 {
398 digit = static_cast<unsigned long long> (c - 'a' + 10);
399 }
400 else if (base == 16 && c >= 'A' && c <= 'F')
401 {
402 digit = static_cast<unsigned long long> (c - 'A' + 10);
403 }
404 else
405 {
406 // A decimal point, an exponent, or a suffix character.
407 result.is_integer = false;
408 return result;
409 }
410
411 if (digit >= base)
412 {
413 // Possible only in a floating-point literal, like `09.5`.
414 result.is_integer = false;
415 return result;
416 }
417
418 if (result.value > (max_value - digit) / base)
419 {
420 result.is_too_large = true;
421 return result;
422 }
423
424 result.value = result.value * base + digit;
425 }
426
427 return result;
428 }

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()​

template <class T, class Exp_T>
T micro_os_plus::micro_test_plus::detail::math::pow (const T base, const Exp_T exp)
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.

85 pow (const T base, const Exp_T exp) noexcept -> T
86 {
87 T result{ 1 };
88 for (Exp_T i{}; i < exp; ++i)
89 result *= base;
90 return result;
91 }

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:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 *
11 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12 * released under the terms of the Boost Version 1.0 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
41
42#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DEPRECATED_INLINES_H_
43#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DEPRECATED_INLINES_H_
44
45// ----------------------------------------------------------------------------
46
47#if defined(__cplusplus)
48
49// ----------------------------------------------------------------------------
50
51#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
52
53#if defined(__GNUC__)
54#pragma GCC diagnostic push
55
56#pragma GCC diagnostic ignored "-Waggregate-return"
57#pragma GCC diagnostic ignored "-Wconversion"
58#if defined(__clang__)
59#pragma clang diagnostic ignored "-Wc++98-compat"
60#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
61#pragma clang diagnostic ignored "-Wpre-c++17-compat"
62#pragma clang diagnostic ignored "-Wc++20-compat"
63#endif // defined(__clang__)
64#endif // defined(__GNUC__)
65
66// ============================================================================
67
69{
70 // --------------------------------------------------------------------------
71 namespace detail::math
72 {
83 template <class T, class Exp_T>
84 constexpr auto
85 pow (const T base, const Exp_T exp) noexcept -> T
86 {
87 T result{ 1 };
88 for (Exp_T i{}; i < exp; ++i)
89 result *= base;
90 return result;
91 }
92
99 template <bool Fraction, char... Cs>
100 consteval auto
101 count_literal_digits (void) -> std::size_t
102 {
103 std::size_t count = 0;
104 bool is_fraction = false;
105 for (const char c : { Cs... })
106 {
107 if (c == '.')
108 {
109 is_fraction = true;
110 }
111 else if (c >= '0' and c <= '9' and is_fraction == Fraction)
112 {
113 ++count;
114 }
115 }
116 return count;
117 }
118
132 template <class T, char... Cs>
133 consteval auto
134 num (void) -> T
135 {
136 static_assert (
137 ((Cs == '.' or Cs == '\'' or (Cs >= '0' and Cs <= '9')) and ...),
138 "µTest++: a floating-point literal must be written with decimal "
139 "digits and a decimal point, without an exponent");
140 static_assert (
141 count_literal_digits<false, Cs...> ()
142 <= static_cast<std::size_t> (std::numeric_limits<T>::digits10),
143 "µTest++: the floating-point literal has too many "
144 "digits before the decimal point");
145 T result{};
146 for (const char c : { Cs... })
147 {
148 if (c == '.')
149 {
150 break;
151 }
152 if (c >= '0' and c <= '9')
153 {
154 result = static_cast<T> (result * static_cast<T> (10)
155 + static_cast<T> (c - '0'));
156 }
157 }
158 return result;
159 }
160
175 template <class T, char... Cs>
176 consteval auto
177 den (void) -> T
178 {
179 static_assert ((... || (Cs == '.')),
180 "den(): no decimal point in literal");
181 // The result has as many digits as the decimals, and it must fit in
182 // `T`.
183 static_assert (
184 count_literal_digits<true, Cs...> ()
185 <= static_cast<std::size_t> (std::numeric_limits<T>::digits10),
186 "µTest++: the floating-point literal has too many "
187 "decimals");
188 T result{};
189 bool is_fraction = false;
190 for (const char c : { Cs... })
191 {
192 if (c == '.')
193 {
194 is_fraction = true;
195 }
196 else if (is_fraction and c >= '0' and c <= '9')
197 {
198 // The digit separators are skipped.
199 result = static_cast<T> (result * static_cast<T> (10)
200 + static_cast<T> (c - '0'));
201 }
202 }
203 return result;
204 }
205
218 template <class T, char... Cs>
219 consteval auto
220 den_size (void) -> T
221 {
222 static_assert ((... || (Cs == '.')),
223 "den_size(): no decimal point in literal");
224 return static_cast<T> (count_literal_digits<true, Cs...> ());
225 }
226
256 template <class T, class Value_T>
257 constexpr auto
258 count_decimals (Value_T value) -> T
259 {
260 constexpr auto precision = Value_T (1e-7);
261 // From this magnitude upwards all values are integers.
262 constexpr auto integral_limit
263 = min_value (Value_T (1) / std::numeric_limits<Value_T>::epsilon (),
264 Value_T (1ULL << 63));
265
266 value = abs (value);
267
268#if defined(__GNUC__)
269#pragma GCC diagnostic push
270#pragma GCC diagnostic ignored "-Wfloat-equal"
271#endif // defined(__GNUC__)
272 if (value == Value_T (0))
273 {
274 // A zero has no decimals.
275 return T{};
276 }
277#if defined(__GNUC__)
278#pragma GCC diagnostic pop
279#endif // defined(__GNUC__)
280
281 T result{};
282 for (;;)
283 {
284 value *= 10;
285 ++result;
286
287 // Also true for infinities and NaNs.
288 if (not(value < integral_limit))
289 {
290 break;
291 }
292
293 const auto fraction = value
294 - static_cast<Value_T> (
295 static_cast<unsigned long long> (value));
296 // Below one, the distance is to one, not to zero, so that the
297 // leading zeros of a small value are counted.
298 const auto distance
299 = (value < Value_T (1))
300 ? Value_T (1) - fraction
301 : min_value (fraction, Value_T (1) - fraction);
302 if (distance <= precision)
303 {
304 break;
305 }
306 }
307
308 return result;
309 }
310
324 template <class Value_T>
325 constexpr auto
326 decimal_epsilon (Value_T value) -> Value_T
327 {
328 const auto decimals = count_decimals<unsigned long long> (value);
329 if (decimals == 0
330 or decimals > static_cast<unsigned long long> (
331 std::numeric_limits<Value_T>::max_exponent10))
332 {
333 return Value_T{};
334 }
335 return Value_T (1) / pow (Value_T (10), decimals);
336 }
337
352 template <char... Cs>
353 consteval auto
355 {
356 constexpr std::array<char, sizeof...(Cs)> cs{ Cs... };
357 constexpr unsigned long long max_value
358 = std::numeric_limits<unsigned long long>::max ();
359
360 integer_literal result{ 0, true, false };
361
362 unsigned long long base = 10;
363 std::size_t i = 0;
364 if (cs.size () > 1 && cs[0] == '0')
365 {
366 if (cs[1] == 'x' || cs[1] == 'X')
367 {
368 base = 16;
369 i = 2;
370 }
371 else if (cs[1] == 'b' || cs[1] == 'B')
372 {
373 base = 2;
374 i = 2;
375 }
376 else
377 {
378 base = 8;
379 i = 1;
380 }
381 }
382
383 for (; i < cs.size (); ++i)
384 {
385 const char c = cs[i];
386 if (c == '\'')
387 {
388 continue;
389 }
390
391 unsigned long long digit = 0;
392 if (c >= '0' && c <= '9')
393 {
394 digit = static_cast<unsigned long long> (c - '0');
395 }
396 else if (base == 16 && c >= 'a' && c <= 'f')
397 {
398 digit = static_cast<unsigned long long> (c - 'a' + 10);
399 }
400 else if (base == 16 && c >= 'A' && c <= 'F')
401 {
402 digit = static_cast<unsigned long long> (c - 'A' + 10);
403 }
404 else
405 {
406 // A decimal point, an exponent, or a suffix character.
407 result.is_integer = false;
408 return result;
409 }
410
411 if (digit >= base)
412 {
413 // Possible only in a floating-point literal, like `09.5`.
414 result.is_integer = false;
415 return result;
416 }
417
418 if (result.value > (max_value - digit) / base)
419 {
420 result.is_too_large = true;
421 return result;
422 }
423
424 result.value = result.value * base + digit;
425 }
426
427 return result;
428 }
429
446 template <class T, char... Cs>
447 consteval auto
448 integer_magnitude (void) -> unsigned long long
449 {
450 constexpr integer_literal literal = parse_integer_literal<Cs...> ();
451 constexpr unsigned long long max_magnitude
452 = static_cast<unsigned long long> (std::numeric_limits<T>::max ())
453 + (std::numeric_limits<T>::is_signed ? 1u : 0u);
454 constexpr bool fits = literal.is_integer && !literal.is_too_large
455 && literal.value <= max_magnitude;
456
457 static_assert (literal.is_integer,
458 "µTest++: an integer literal must not have a decimal "
459 "point or an exponent");
460 static_assert (!literal.is_integer || !literal.is_too_large,
461 "µTest++: the integer literal is too large");
462 static_assert (!literal.is_integer || literal.is_too_large || fits,
463 "µTest++: the integer literal value does not fit in the "
464 "type of the literal");
465
466 return fits ? literal.value : 0;
467 }
468
469 // ------------------------------------------------------------------------
470 // ------------------------------------------------------------------------
471 } // namespace detail::math
472
473 namespace detail
474 {
475 // ========================================================================
476
481 template <class T>
482 constexpr value_base<T>::value_base (const T& v) noexcept : value_{ v }
483 {
484 }
485
490 template <class T>
491 constexpr value_base<T>::
492 operator T () const noexcept
493 {
494 return value_;
495 }
496
502 template <class T>
503 constexpr const T&
504 value_base<T>::get (void) const noexcept
505 {
506 return value_;
507 }
508
509 // ------------------------------------------------------------------------
510
515 template <auto N>
517 : value_base<decltype (N)>{ N }
518 {
519 }
520
530 template <auto N>
531 constexpr auto
533 {
534 // Not named `value_type`, which would shadow the member inherited
535 // from the base (`-Wshadow`).
536 using constant_type = decltype (N);
537
538 if constexpr (!std::is_signed_v<constant_type>)
539 {
541 - N)>{};
542 }
543 else if constexpr (N == std::numeric_limits<constant_type>::min ())
544 {
545 static_assert (N != std::numeric_limits<constant_type>::min (),
546 "µTest++: the negation of the minimum value does "
547 "not fit in the type of the literal");
548 return *this;
549 }
550 else
551 {
553 }
554 }
555
556 // ------------------------------------------------------------------------
557
563 template <class T>
564 constexpr auto
566 {
568 }
569
570 // ------------------------------------------------------------------------
571
579 template <class T, char... Cs>
580 constexpr auto
582 {
583 constexpr unsigned long long magnitude
584 = math::integer_magnitude<T, Cs...> ();
585
586 if constexpr (magnitude > static_cast<unsigned long long> (
587 std::numeric_limits<T>::max ()))
588 {
590 }
591 else
592 {
593 return integral_constant<static_cast<T> (magnitude)>{};
594 }
595 }
596
597 // ------------------------------------------------------------------------
598
603 template <class T, auto N, auto D, auto Size, auto P>
605 operator T () const noexcept
606 {
607 return value;
608 }
609
614 template <class T, auto N, auto D, auto Size, auto P>
615 constexpr T
617 {
618 return value;
619 }
620
626 template <class T, auto N, auto D, auto Size, auto P>
627 constexpr auto
629 {
630 return floating_point_constant<T, N, D, Size, -P>{};
631 }
632
633 // ------------------------------------------------------------------------
634
635 template <class T>
636 constexpr value<T>::value (const T& _value) noexcept
637 : value_base<T>{ _value }
638 {
639 }
640
641 // ------------------------------------------------------------------------
642
647 constexpr named_bool::named_bool (std::string_view name) noexcept
648 : name_{ name }
649 {
650 }
651
656 constexpr named_bool::
657 operator value_type () const noexcept
658 {
659 return true;
660 }
661
666 constexpr std::string_view
667 named_bool::name (void) const noexcept
668 {
669 return name_;
670 }
671
672 // ------------------------------------------------------------------------
673 } // namespace detail
674
675 // --------------------------------------------------------------------------
676
682 // Deprecated since 6.0.0; use negate().
683 template <class Expr_T>
684 constexpr auto
685 _not (Expr_T&& expr)
686 {
687 return negate (std::forward<Expr_T> (expr));
688 }
689
695 // Deprecated since 6.0.0; use all_of().
696 template <class Lhs_T, class Rhs_T>
697 constexpr auto
698 _and (Lhs_T&& lhs, Rhs_T&& rhs)
699 {
700 return all_of (std::forward<Lhs_T> (lhs), std::forward<Rhs_T> (rhs));
701 }
702
708 // Deprecated since 6.0.0; use any_of().
709 template <class Lhs_T, class Rhs_T>
710 constexpr auto
711 _or (Lhs_T&& lhs, Rhs_T&& rhs)
712 {
713 return any_of (std::forward<Lhs_T> (lhs), std::forward<Rhs_T> (rhs));
714 }
715
716 // --------------------------------------------------------------------------
717
722 // Deprecated since 6.0.0; use const_cast<T&>.
723 template <class T>
724 constexpr auto
725 mut (const T& t) noexcept -> T&
726 {
727 return const_cast<T&> (t);
728 }
729
730 // --------------------------------------------------------------------------
731
732 namespace operators
733 {
734 // ========================================================================
735
743 template <class Lhs_T, class Rhs_T>
744 requires extension::any_op<std::remove_cvref_t<Lhs_T>,
745 std::remove_cvref_t<Rhs_T>>
746 constexpr auto
747 operator==(Lhs_T&& lhs, Rhs_T&& rhs)
748 {
749 return detail::compare_op{ std::forward<Lhs_T> (lhs),
750 std::forward<Rhs_T> (rhs),
752 }
753
761 template <class Lhs_T, class Rhs_T>
763 std::remove_cvref_t<Rhs_T>>
764 constexpr auto
765 operator!=(Lhs_T&& lhs, Rhs_T&& rhs)
766 {
767 return detail::compare_op{ std::forward<Lhs_T> (lhs),
768 std::forward<Rhs_T> (rhs),
770 }
771
779 template <class Lhs_T, class Rhs_T>
781 std::remove_cvref_t<Rhs_T>>
782 constexpr auto
783 operator>(Lhs_T&& lhs, Rhs_T&& rhs)
784 {
785 return detail::compare_op{ std::forward<Lhs_T> (lhs),
786 std::forward<Rhs_T> (rhs),
788 }
789
797 template <class Lhs_T, class Rhs_T>
799 std::remove_cvref_t<Rhs_T>>
800 constexpr auto
801 operator>=(Lhs_T&& lhs, Rhs_T&& rhs)
802 {
803 return detail::compare_op{ std::forward<Lhs_T> (lhs),
804 std::forward<Rhs_T> (rhs),
806 }
807
815 template <class Lhs_T, class Rhs_T>
817 std::remove_cvref_t<Rhs_T>>
818 constexpr auto
819 operator<(Lhs_T&& lhs, Rhs_T&& rhs)
820 {
821 return detail::compare_op{ std::forward<Lhs_T> (lhs),
822 std::forward<Rhs_T> (rhs), detail::less{} };
823 }
824
832 template <class Lhs_T, class Rhs_T>
834 std::remove_cvref_t<Rhs_T>>
835 constexpr auto
836 operator<=(Lhs_T&& lhs, Rhs_T&& rhs)
837 {
838 return detail::compare_op{ std::forward<Lhs_T> (lhs),
839 std::forward<Rhs_T> (rhs),
841 }
842
850 template <class Lhs_T, class Rhs_T>
852 std::remove_cvref_t<Rhs_T>>
853 constexpr auto
854 operator and (Lhs_T&& lhs, Rhs_T&& rhs)
855 {
856 return detail::and_op{ std::forward<Lhs_T> (lhs),
857 std::forward<Rhs_T> (rhs) };
858 }
859
867 template <class Lhs_T, class Rhs_T>
869 std::remove_cvref_t<Rhs_T>>
870 constexpr auto
871 operator or (Lhs_T&& lhs, Rhs_T&& rhs)
872 {
873 return detail::or_op{ std::forward<Lhs_T> (lhs),
874 std::forward<Rhs_T> (rhs) };
875 }
876
883 template <class T>
885 constexpr auto
886 operator not(T&& t)
887 {
888 // Not `not_op{ t }`, which would copy an operand that is itself
889 // a `not_op`, instead of negating it.
890 return detail::not_op<detail::stored_operand_t<T>>{ std::forward<T> (
891 t) };
892 }
893
894 // ------------------------------------------------------------------------
895 } // namespace operators
896
897 // --------------------------------------------------------------------------
898
899 namespace literals
900 {
901
909 template <char... Cs>
910 constexpr auto
911 operator""_i ()
912 {
913 return detail::integral_literal<int, Cs...> ();
914 }
915
923 template <char... Cs>
924 constexpr auto
925 operator""_s ()
926 {
927 return detail::integral_literal<short, Cs...> ();
928 }
929
937 template <char... Cs>
938 constexpr auto
939 operator""_c ()
940 {
941 return detail::integral_literal<char, Cs...> ();
942 }
943
951 template <char... Cs>
952 constexpr auto
953 operator""_sc ()
954 {
955 return detail::integral_literal<signed char, Cs...> ();
956 }
957
965 template <char... Cs>
966 constexpr auto
967 operator""_l ()
968 {
969 return detail::integral_literal<long, Cs...> ();
970 }
971
979 template <char... Cs>
980 constexpr auto
981 operator""_ll ()
982 {
983 return detail::integral_literal<long long, Cs...> ();
984 }
985
993 template <char... Cs>
994 constexpr auto
995 operator""_u ()
996 {
997 return detail::integral_literal<unsigned, Cs...> ();
998 }
999
1007 template <char... Cs>
1008 constexpr auto
1009 operator""_uc ()
1010 {
1011 return detail::integral_literal<unsigned char, Cs...> ();
1012 }
1013
1021 template <char... Cs>
1022 constexpr auto
1023 operator""_us ()
1024 {
1025 return detail::integral_literal<unsigned short, Cs...> ();
1026 }
1027
1035 template <char... Cs>
1036 constexpr auto
1037 operator""_ul ()
1038 {
1039 return detail::integral_literal<unsigned long, Cs...> ();
1040 }
1041
1049 template <char... Cs>
1050 constexpr auto
1051 operator""_ull ()
1052 {
1053 return detail::integral_literal<unsigned long long, Cs...> ();
1054 }
1055
1063 template <char... Cs>
1064 constexpr auto
1065 operator""_i8 ()
1066 {
1067 return detail::integral_literal<std::int8_t, Cs...> ();
1068 }
1069
1077 template <char... Cs>
1078 constexpr auto
1079 operator""_i16 ()
1080 {
1081 return detail::integral_literal<std::int16_t, Cs...> ();
1082 }
1083
1091 template <char... Cs>
1092 constexpr auto
1093 operator""_i32 ()
1094 {
1095 return detail::integral_literal<std::int32_t, Cs...> ();
1096 }
1097
1105 template <char... Cs>
1106 constexpr auto
1107 operator""_i64 ()
1108 {
1109 return detail::integral_literal<std::int64_t, Cs...> ();
1110 }
1111
1119 template <char... Cs>
1120 constexpr auto
1121 operator""_u8 ()
1122 {
1123 return detail::integral_literal<std::uint8_t, Cs...> ();
1124 }
1125
1133 template <char... Cs>
1134 constexpr auto
1135 operator""_u16 ()
1136 {
1137 return detail::integral_literal<std::uint16_t, Cs...> ();
1138 }
1139
1147 template <char... Cs>
1148 constexpr auto
1149 operator""_u32 ()
1150 {
1151 return detail::integral_literal<std::uint32_t, Cs...> ();
1152 }
1153
1161 template <char... Cs>
1162 constexpr auto
1163 operator""_u64 ()
1164 {
1165 return detail::integral_literal<std::uint64_t, Cs...> ();
1166 }
1167
1176 template <char... Cs>
1177 constexpr auto
1178 operator""_f ()
1179 {
1181 float, detail::math::num<unsigned long long, Cs...> (),
1183 detail::math::den_size<unsigned long long, Cs...> ()>{};
1184 }
1185
1194 template <char... Cs>
1195 constexpr auto
1196 operator""_d ()
1197 {
1199 double, detail::math::num<unsigned long long, Cs...> (),
1201 detail::math::den_size<unsigned long long, Cs...> ()>{};
1202 }
1203
1212 template <char... Cs>
1213 constexpr auto
1214 operator""_ld ()
1215 {
1217 long double, detail::math::num<unsigned long long, Cs...> (),
1219 detail::math::den_size<unsigned long long, Cs...> ()>{};
1220 }
1221
1237 constexpr auto
1238 operator""_b (const char* name, decltype (sizeof ("")) size)
1239 {
1240 return detail::named_bool{ std::string_view{ name, size } };
1241 }
1242
1243 // ------------------------------------------------------------------------
1244 } // namespace literals
1245
1246 // ==========================================================================
1247
1248#if defined(__GNUC__)
1249#pragma GCC diagnostic push
1250// The definition of the deprecated class.
1251#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1252#endif // defined(__GNUC__)
1253
1259 template <class T>
1260 constexpr to_t<T>::to_t (const T& t) : detail::value<T>{ t }
1261 {
1262 }
1263
1264#if defined(__GNUC__)
1265#pragma GCC diagnostic pop
1266#endif // defined(__GNUC__)
1267
1274 template <class T>
1275 requires std::is_floating_point_v<T>
1276 constexpr auto
1277 approx (T value, std::type_identity_t<T> epsilon) noexcept
1279 {
1280 return detail::value<T>{ value, epsilon };
1281 }
1282
1283} // namespace micro_os_plus::micro_test_plus
1284
1285// ============================================================================
1286
1288{
1289 // ==========================================================================
1290
1295 // Deprecated since 6.0.0, as the whole `timestamp` class; the timings are
1296 // internal.
1297 inline timestamp::timestamp (const timespec& ts) noexcept : value_{ ts }
1298 {
1299 }
1300
1306 // Deprecated since 6.0.0, as the whole `timestamp` class; the timings are
1307 // internal.
1308 inline bool
1309 timestamp::has_clock (void) const noexcept
1310 {
1311 return value_.tv_sec != 0 || value_.tv_nsec != 0;
1312 }
1313
1319 // Deprecated since 6.0.0, as the whole `timestamp` class; the timings are
1320 // internal.
1321 inline timespec&
1322 timestamp::value (void) noexcept
1323 {
1324 return value_;
1325 }
1326
1331 // Deprecated since 6.0.0, as the whole `timestamp` class; the timings are
1332 // internal.
1333 inline const timespec&
1334 timestamp::value (void) const noexcept
1335 {
1336 return value_;
1337 }
1338
1339 // --------------------------------------------------------------------------
1340} // namespace micro_os_plus::micro_test_plus::detail
1341
1342#if defined(__GNUC__)
1343#pragma GCC diagnostic pop
1344#endif // defined(__GNUC__)
1345
1346#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
1347
1348// ----------------------------------------------------------------------------
1349
1350#endif // defined(__cplusplus)
1351
1352// ----------------------------------------------------------------------------
1353
1354#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DEPRECATED_INLINES_H_
1355
1356// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.