micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T > Struct Template Reference

Less than or equal comparator struct template. More...

#include <micro-os-plus/micro-test-plus.h>

Inheritance diagram for micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >:

Public Member Functions

constexpr le_ (const Lhs_T &lhs={}, const Rhs_T &rhs={})
 Constructs a less than or equal comparator for the given operands.
constexpr auto lhs (void) const
 Retrieves the left-hand operand.
constexpr operator bool () const
 Conversion operator to boolean.
constexpr auto rhs (void) const
 Retrieves the right-hand operand.

Public Attributes

const Lhs_T lhs_ {}
 Stores the left-hand operand.
const Rhs_T rhs_ {}
 Stores the right-hand operand.
const bool value_ {}
 Stores the result of the less than or equal comparison.

Detailed Description

template<class Lhs_T, class Rhs_T>
struct micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >
Template Parameters
Lhs_TThe type of the left-hand operand.
Rhs_TThe type of the right-hand operand.

The le_ struct template provides a type-safe mechanism for evaluating whether the left-hand operand is less than or equal to the right-hand operand within the framework.

This comparator supports a variety of operand types, including those with static values and generic types. For types with static values, the comparison is performed directly. For all other types, the generic getter is used to retrieve and compare the values.

The implementation is optimised for use in embedded environments and supports both compile-time and run-time evaluation.

All definitions are intended for internal use within the framework and are implemented in the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

Definition at line 1030 of file detail.h.

Constructor & Destructor Documentation

◆ le_()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::le_ ( const Lhs_T & lhs = {},
const Rhs_T & rhs = {} )
inlineconstexpr
Parameters
lhsThe left-hand operand.
rhsThe right-hand operand.

Evaluates whether the left-hand operand is less than or equal to the right-hand operand at construction, supporting static values and generic types. The result is stored in the value_ member for efficient access.

Definition at line 1045 of file detail.h.

1045 {}, const Rhs_T& rhs = {})
1046 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
1047 using std::operator<=;
1048
1049#if defined(__GNUC__)
1050#pragma GCC diagnostic push
1051#pragma GCC diagnostic ignored "-Wconversion"
1052#pragma GCC diagnostic ignored "-Wdouble-promotion"
1053#pragma GCC diagnostic ignored "-Wsign-compare"
1054#if defined(__clang__)
1055#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
1056#pragma clang diagnostic ignored "-Wpedantic"
1057#endif
1058#endif
1061 {
1062 return Lhs_T::value <= Rhs_T::value;
1063 }
1064 else
1065 {
1066 return get (lhs_) <= get (rhs_);
1067 }
1068#if defined(__GNUC__)
1069#pragma GCC diagnostic pop
1070#endif
1071 }() }
1072 {
1073 }
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
Definition detail.h:223
Less than or equal comparator struct template.
Definition detail.h:1031
constexpr auto rhs(void) const
Retrieves the right-hand operand.
Definition detail.h:1125
const Lhs_T lhs_
Stores the left-hand operand.
Definition detail.h:1133
const bool value_
Stores the result of the less than or equal comparison.
Definition detail.h:1143
const Rhs_T rhs_
Stores the right-hand operand.
Definition detail.h:1138
constexpr auto lhs(void) const
Retrieves the left-hand operand.
Definition detail.h:1107

References lhs().

Member Function Documentation

◆ lhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::lhs ( void ) const
inlinenodiscardconstexpr
Parameters
None.
Returns
The extracted left-hand operand.

Returns the value of the left-hand operand, applying the generic getter to ensure correct extraction for both custom and standard types.

Definition at line 1107 of file detail.h.

1108 {
1109 return get (lhs_);
1110 }

References micro_os_plus::micro_test_plus::detail::get(), and lhs_.

Referenced by le_(), and micro_os_plus::micro_test_plus::test_reporter::operator<<().

◆ operator bool()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::operator bool ( ) const
inlinenodiscardconstexpr
Parameters
None.
Return values
trueThe left-hand operand is less than or equal to the right-hand operand.
falseOtherwise.

Returns the result of the less than or equal comparison.

Definition at line 1088 of file detail.h.

1089 {
1090 return value_;
1091 }

References value_.

◆ rhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::rhs ( void ) const
inlinenodiscardconstexpr
Parameters
None.
Returns
The extracted right-hand operand.

Returns the value of the right-hand operand, applying the generic getter to ensure correct extraction for both custom and standard types.

Definition at line 1125 of file detail.h.

1126 {
1127 return get (rhs_);
1128 }

References micro_os_plus::micro_test_plus::detail::get(), and rhs_.

Referenced by micro_os_plus::micro_test_plus::test_reporter::operator<<().

Member Data Documentation

◆ lhs_

template<class Lhs_T, class Rhs_T>
const Lhs_T micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::lhs_ {}

Definition at line 1133 of file detail.h.

1133{};

Referenced by lhs().

◆ rhs_

template<class Lhs_T, class Rhs_T>
const Rhs_T micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::rhs_ {}

Definition at line 1138 of file detail.h.

1138{};

Referenced by rhs().

◆ value_

template<class Lhs_T, class Rhs_T>
const bool micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::value_ {}

Definition at line 1143 of file detail.h.

1143{};

Referenced by operator bool().


The documentation for this struct was generated from the following file: