42#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DEPRECATED_INLINES_H_
43#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DEPRECATED_INLINES_H_
47#if defined(__cplusplus)
51#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
54#pragma GCC diagnostic push
56#pragma GCC diagnostic ignored "-Waggregate-return"
57#pragma GCC diagnostic ignored "-Wconversion"
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"
83 template <
class T,
class Exp_T>
85 pow (
const T base,
const Exp_T exp)
noexcept -> T
88 for (Exp_T i{}; i < exp; ++i)
99 template <
bool Fraction,
char... Cs>
103 std::size_t count = 0;
104 bool is_fraction =
false;
105 for (
const char c : { Cs... })
111 else if (c >=
'0' and c <=
'9' and is_fraction == Fraction)
132 template <
class T,
char... Cs>
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");
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");
146 for (
const char c : { Cs... })
152 if (c >=
'0' and c <=
'9')
154 result =
static_cast<T
> (result *
static_cast<T
> (10)
155 +
static_cast<T
> (c -
'0'));
175 template <
class T,
char... Cs>
179 static_assert ((... || (Cs ==
'.')),
180 "den(): no decimal point in literal");
185 <=
static_cast<std::size_t
> (std::numeric_limits<T>::digits10),
186 "µTest++: the floating-point literal has too many "
189 bool is_fraction =
false;
190 for (
const char c : { Cs... })
196 else if (is_fraction and c >=
'0' and c <=
'9')
199 result =
static_cast<T
> (result *
static_cast<T
> (10)
200 +
static_cast<T
> (c -
'0'));
218 template <
class T,
char... Cs>
222 static_assert ((... || (Cs ==
'.')),
223 "den_size(): no decimal point in literal");
256 template <
class T,
class Value_T>
260 constexpr auto precision = Value_T (1e-7);
262 constexpr auto integral_limit
263 =
min_value (Value_T (1) / std::numeric_limits<Value_T>::epsilon (),
264 Value_T (1ULL << 63));
269#pragma GCC diagnostic push
270#pragma GCC diagnostic ignored "-Wfloat-equal"
272 if (
value == Value_T (0))
278#pragma GCC diagnostic pop
288 if (not(
value < integral_limit))
293 const auto fraction =
value
294 -
static_cast<Value_T
> (
295 static_cast<unsigned long long> (
value));
299 = (
value < Value_T (1))
300 ? Value_T (1) - fraction
301 :
min_value (fraction, Value_T (1) - fraction);
302 if (distance <= precision)
324 template <
class Value_T>
330 or decimals >
static_cast<unsigned long long> (
331 std::numeric_limits<Value_T>::max_exponent10))
335 return Value_T (1) /
pow (Value_T (10), decimals);
352 template <
char... Cs>
356 constexpr std::array<char,
sizeof...(Cs)> cs{ Cs... };
357 constexpr unsigned long long max_value
358 = std::numeric_limits<unsigned long long>::max ();
362 unsigned long long base = 10;
364 if (cs.size () > 1 && cs[0] ==
'0')
366 if (cs[1] ==
'x' || cs[1] ==
'X')
371 else if (cs[1] ==
'b' || cs[1] ==
'B')
383 for (; i < cs.size (); ++i)
385 const char c = cs[i];
391 unsigned long long digit = 0;
392 if (c >=
'0' && c <=
'9')
394 digit =
static_cast<unsigned long long> (c -
'0');
396 else if (base == 16 && c >=
'a' && c <=
'f')
398 digit =
static_cast<unsigned long long> (c -
'a' + 10);
400 else if (base == 16 && c >=
'A' && c <=
'F')
402 digit =
static_cast<unsigned long long> (c -
'A' + 10);
418 if (result.
value > (max_value - digit) / base)
446 template <
class T,
char... 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);
455 && literal.
value <= max_magnitude;
458 "µTest++: an integer literal must not have a decimal "
459 "point or an exponent");
461 "µTest++: the integer literal is too large");
463 "µTest++: the integer literal value does not fit in the "
464 "type of the literal");
466 return fits ? literal.
value : 0;
492 operator T () const noexcept
536 using constant_type =
decltype (N);
538 if constexpr (!std::is_signed_v<constant_type>)
543 else if constexpr (N == std::numeric_limits<constant_type>::min ())
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");
579 template <
class T,
char... Cs>
583 constexpr unsigned long long magnitude
586 if constexpr (magnitude >
static_cast<unsigned long long> (
587 std::numeric_limits<T>::max ()))
603 template <
class T, auto N, auto D, auto Size, auto P>
605 operator T () const noexcept
614 template <
class T, auto N, auto D, auto Size, auto P>
626 template <
class T, auto N, auto D, auto Size, auto P>
656 constexpr named_bool::
666 constexpr std::string_view
683 template <
class Expr_T>
687 return negate (std::forward<Expr_T> (expr));
696 template <
class Lhs_T,
class Rhs_T>
698 _and (Lhs_T&& lhs, Rhs_T&& rhs)
700 return all_of (std::forward<Lhs_T> (lhs), std::forward<Rhs_T> (rhs));
709 template <
class Lhs_T,
class Rhs_T>
711 _or (Lhs_T&& lhs, Rhs_T&& rhs)
713 return any_of (std::forward<Lhs_T> (lhs), std::forward<Rhs_T> (rhs));
725 mut (
const T& t)
noexcept -> T&
727 return const_cast<T&
> (t);
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>>
750 std::forward<Rhs_T> (rhs),
761 template <
class Lhs_T,
class Rhs_T>
763 std::remove_cvref_t<Rhs_T>>
768 std::forward<Rhs_T> (rhs),
779 template <
class Lhs_T,
class Rhs_T>
781 std::remove_cvref_t<Rhs_T>>
786 std::forward<Rhs_T> (rhs),
797 template <
class Lhs_T,
class Rhs_T>
799 std::remove_cvref_t<Rhs_T>>
804 std::forward<Rhs_T> (rhs),
815 template <
class Lhs_T,
class Rhs_T>
817 std::remove_cvref_t<Rhs_T>>
832 template <
class Lhs_T,
class Rhs_T>
834 std::remove_cvref_t<Rhs_T>>
839 std::forward<Rhs_T> (rhs),
850 template <
class Lhs_T,
class Rhs_T>
852 std::remove_cvref_t<Rhs_T>>
854 operator and (Lhs_T&& lhs, Rhs_T&& rhs)
857 std::forward<Rhs_T> (rhs) };
867 template <
class Lhs_T,
class Rhs_T>
869 std::remove_cvref_t<Rhs_T>>
871 operator or (Lhs_T&& lhs, Rhs_T&& rhs)
874 std::forward<Rhs_T> (rhs) };
909 template <
char... Cs>
923 template <
char... Cs>
937 template <
char... Cs>
951 template <
char... Cs>
965 template <
char... Cs>
979 template <
char... Cs>
993 template <
char... Cs>
1007 template <
char... Cs>
1021 template <
char... Cs>
1035 template <
char... Cs>
1049 template <
char... Cs>
1063 template <
char... Cs>
1077 template <
char... Cs>
1091 template <
char... Cs>
1105 template <
char... Cs>
1119 template <
char... Cs>
1133 template <
char... Cs>
1147 template <
char... Cs>
1161 template <
char... Cs>
1176 template <
char... Cs>
1194 template <
char... Cs>
1212 template <
char... Cs>
1238 operator""_b (
const char* name,
decltype (
sizeof (
"")) size)
1248#if defined(__GNUC__)
1249#pragma GCC diagnostic push
1251#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1264#if defined(__GNUC__)
1265#pragma GCC diagnostic pop
1275 requires std::is_floating_point_v<T>
1277 approx (T value, std::type_identity_t<T> epsilon)
noexcept
1333 inline const timespec&
1342#if defined(__GNUC__)
1343#pragma GCC diagnostic pop
timespec & value(void) noexcept
Returns the stored time, for modification.
timestamp(void) noexcept
Constructs a timestamp with the current time.
timespec value_
The stored time.
bool has_clock(void) const noexcept
Checks whether the value is a clock reading.
Concept satisfied when at least one of two types is a framework expression type.
Concept satisfied when a type is a framework expression type.
to_sc _sc
Deprecated strongly-typed wrapper for signed char values, the v5.0.1 name of to_sc.
to_u64 _u64
Deprecated strongly-typed wrapper for std::uint64_t values, the v5.0.1 name of to_u64.
to_f _f
Deprecated strongly-typed wrapper for float values, the v5.0.1 name of to_f.
to_i8 _i8
Deprecated strongly-typed wrapper for std::int8_t values, the v5.0.1 name of to_i8.
to_i64 _i64
Deprecated strongly-typed wrapper for std::int64_t values, the v5.0.1 name of to_i64.
to_ul _ul
Deprecated strongly-typed wrapper for unsigned long values, the v5.0.1 name of to_ul.
to_l _l
Deprecated strongly-typed wrapper for long values, the v5.0.1 name of to_l.
to_s _s
Deprecated strongly-typed wrapper for short values, the v5.0.1 name of to_s.
to_u32 _u32
Deprecated strongly-typed wrapper for std::uint32_t values, the v5.0.1 name of to_u32.
to_us _us
Deprecated strongly-typed wrapper for unsigned short values, the v5.0.1 name of to_us.
to_d _d
Deprecated strongly-typed wrapper for double values, the v5.0.1 name of to_d.
to_i _i
Deprecated strongly-typed wrapper for int values, the v5.0.1 name of to_i.
to_i32 _i32
Deprecated strongly-typed wrapper for std::int32_t values, the v5.0.1 name of to_i32.
to_u16 _u16
Deprecated strongly-typed wrapper for std::uint16_t values, the v5.0.1 name of to_u16.
to_ll _ll
Deprecated strongly-typed wrapper for long long values, the v5.0.1 name of to_ll.
to_uc _uc
Deprecated strongly-typed wrapper for unsigned char values, the v5.0.1 name of to_uc.
to_u _u
Deprecated strongly-typed wrapper for unsigned values, the v5.0.1 name of to_u.
to_ld _ld
Deprecated strongly-typed wrapper for long double values, the v5.0.1 name of to_ld.
to_i16 _i16
Deprecated strongly-typed wrapper for std::int16_t values, the v5.0.1 name of to_i16.
to_b _b
Deprecated strongly-typed wrapper for bool values, the v5.0.1 name of to_b.
to_ull _ull
Deprecated strongly-typed wrapper for unsigned long long values, the v5.0.1 name of to_ull.
to_u8 _u8
Deprecated strongly-typed wrapper for std::uint8_t values, the v5.0.1 name of to_u8.
to_c _c
Deprecated strongly-typed wrapper for char values, the v5.0.1 name of to_c.
constexpr auto mut(const T &t) noexcept -> T &
Deprecated generic mutator to remove const qualification from a reference.
constexpr auto _or(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated generic logical (inclusive) or operation, the v5.0.1 name of any_of().
constexpr auto _and(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated generic logical and operation, the v5.0.1 name of all_of().
constexpr auto _not(Expr_T &&expr)
Deprecated generic logical not operation, the v5.0.1 name of negate().
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.
constexpr auto operator!=(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated non-equality operator.
constexpr auto operator<(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated less than operator.
constexpr auto operator==(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated equality operator.
constexpr auto operator>=(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated greater than or equal operator.
constexpr auto operator<=(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated less than or equal operator.
constexpr auto operator>(Lhs_T &&lhs, Rhs_T &&rhs)
Deprecated greater than operator.
constexpr auto all_of(First_T &&first, Second_T &&second, Rest_T &&... rest)
Generic logical and operation, for two or more operands.
constexpr auto any_of(First_T &&first, Second_T &&second, Rest_T &&... rest)
Generic logical (inclusive) or operation, for two or more operands.
constexpr auto negate(Expr_T &&expr)
Generic logical not operation.
Internal mathematical utilities for the µTest++ testing framework.
constexpr auto pow(const T base, const Exp_T exp) noexcept -> T
Generic exponentiation function to compute the power of a base raised to an exponent.
consteval auto den(void) -> T
Computes the decimal part of a number represented as an array of characters.
consteval auto den_size(void) -> T
Counts the decimal places of a number represented as an array of characters.
consteval auto integer_magnitude(void) -> unsigned long long
Computes the value of an integer literal of type T, before any negation.
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
consteval auto num(void) -> T
Computes the integral part of a decimal floating-point number represented as an array of characters.
consteval auto parse_integer_literal(void) -> integer_literal
Parses the characters of an integer literal.
constexpr auto count_decimals(Value_T value) -> T
Computes the number of decimal places of a value, with a precision of about seven digits.
constexpr auto decimal_epsilon(Value_T value) -> Value_T
Computes the default comparison tolerance of a floating-point value, one unit of its last decimal.
consteval auto count_literal_digits(void) -> std::size_t
Counts the decimal digits of a floating-point literal, before or after the decimal point.
Internal implementation details for the µTest++ framework.
constexpr auto integral_literal(void)
Creates the compile-time constant of an integer literal.
Primary namespace for the µTest++ testing framework.
Logical AND comparator struct template.
Relational comparator struct template.
Equality tag for compare_op.
Struct template representing a generic floating-point constant with custom size and precision.
constexpr T get(void) const noexcept
Getter for the compile-time constant value.
static constexpr auto value
The compile-time constant value.
constexpr auto operator-() const noexcept
Unary minus operator.
Greater than or equal tag for compare_op.
Greater than tag for compare_op.
Struct template representing a generic integral constant.
constexpr integral_constant(void) noexcept
Default constructor.
constexpr auto operator-() const noexcept
Unary minus operator.
Struct template representing the absolute value of the minimum of a signed integral type,...
constexpr auto operator-() const noexcept
Unary minus operator.
Less than or equal tag for compare_op.
Less than tag for compare_op.
The result of parsing the characters of an integer literal.
unsigned long long value
The value of the literal.
bool is_too_large
Whether the value exceeds unsigned long long.
bool is_integer
Whether the characters form an integer literal.
Struct representing a named boolean constant, created by the _b literal.
constexpr std::string_view name(void) const noexcept
Returns the name of the constant.
std::string_view name_
The name of the constant.
bool value_type
The type of the value.
constexpr named_bool(std::string_view name) noexcept
Constructs a named boolean constant with the given name.
Non-equality tag for compare_op.
Logical NOT comparator struct template.
Logical OR comparator struct template.
constexpr value(const T &_value, const T precision) noexcept
Constructs a floating-point value with a specified precision.
Base struct template providing common storage and accessors for run-time value-wrapper types.
T value_
The stored value.
constexpr const T & get(void) const noexcept
Getter for the stored value.
constexpr value_base(const T &v) noexcept
Constructs a value_base with the given value.
Struct template representing a generic value, accessible via a getter.
constexpr value(const T &_value) noexcept
Constructs a value object with the specified value.
constexpr to_t(const T &t)
Constructor for the strongly-typed wrapper.