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

Less than comparator struct template. More...

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

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

Public Member Functions

constexpr lt_ (const Lhs_T &lhs={}, const Rhs_T &rhs={})
 Constructs a less than 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.

Private 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 comparison.

Detailed Description

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

The lt_ struct template provides a type-safe mechanism for evaluating whether the left-hand operand is less than 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 folder to maintain a structured and modular codebase.

Definition at line 884 of file detail.h.

Constructor & Destructor Documentation

◆ lt_()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lt_ ( 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 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 897 of file detail.h.

897 {}, const Rhs_T& rhs = {})
898 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
899 using std::operator<;
900
901#if defined(__GNUC__)
902#pragma GCC diagnostic push
903#pragma GCC diagnostic ignored "-Wconversion"
904#pragma GCC diagnostic ignored "-Wdouble-promotion"
905#pragma GCC diagnostic ignored "-Wsign-compare"
906#if defined(__clang__)
907#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
908#pragma clang diagnostic ignored "-Wpedantic"
909#endif
910#endif
913 {
914 return Lhs_T::value < Rhs_T::value;
915 }
916 else
917 {
918 return get (lhs_) < get (rhs_);
919 }
920#if defined(__GNUC__)
921#pragma GCC diagnostic pop
922#endif
923 }() }
924 {
925 }
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
Definition detail.h:223
Less than comparator struct template.
Definition detail.h:885
const Lhs_T lhs_
Stores the left-hand operand.
Definition detail.h:985
constexpr auto lhs(void) const
Retrieves the left-hand operand.
Definition detail.h:958
constexpr auto rhs(void) const
Retrieves the right-hand operand.
Definition detail.h:976
const bool value_
Stores the result of the less than comparison.
Definition detail.h:995
const Rhs_T rhs_
Stores the right-hand operand.
Definition detail.h:990

References lhs().

Member Function Documentation

◆ lhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::lt_< 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 958 of file detail.h.

959 {
960 return get (lhs_);
961 }

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

Referenced by lt_(), 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::lt_< Lhs_T, Rhs_T >::operator bool ( ) const
inlinenodiscardconstexpr
Parameters
None.
Return values
trueThe left-hand operand is less than the right-hand operand.
falseOtherwise.

Returns the result of the less than comparison.

Definition at line 940 of file detail.h.

941 {
942 return value_;
943 }

References value_.

◆ rhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::lt_< 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 976 of file detail.h.

977 {
978 return get (rhs_);
979 }

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::lt_< Lhs_T, Rhs_T >::lhs_ {}
private

Definition at line 985 of file detail.h.

985{};

Referenced by lhs().

◆ rhs_

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

Definition at line 990 of file detail.h.

990{};

Referenced by rhs().

◆ value_

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

Definition at line 995 of file detail.h.

995{};

Referenced by operator bool().


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