Skip to main content

approx_op Struct Template

Approximate comparator struct template. More...

Declaration​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
struct micro_os_plus::micro_test_plus::detail::approx_op<Lhs_T, Rhs_T, Epsilon_T> { ... }

Included Headers​

Base struct​

structbinary_op<Lhs_T, Rhs_T>

Common base struct template for binary comparators. More...

Public Member Typedefs Index​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
usingop_type = op

Marker identifying the framework expression types. More...

Public Constructors Index​

template <class L, class R, class E>
constexprapprox_op (L &&lhs, R &&rhs, E &&epsilon)

Constructs an approximate comparator for the given operands. More...

Public Operators Index​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
constexproperator bool () const

Conversion operator to boolean. More...

Public Member Functions Index​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
constexpr auto epsilon (void) const -> decltype(auto)

Retrieves the tolerance. More...

template <class Lhs_T, class Rhs_T, class Epsilon_T>
constexpr auto lhs (void) const -> decltype(auto)

Retrieves the left-hand operand. More...

template <class Lhs_T, class Rhs_T, class Epsilon_T>
constexpr auto rhs (void) const -> decltype(auto)

Retrieves the right-hand operand. More...

Private Member Attributes Index​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Epsilon_Tepsilon_

The stored tolerance. More...

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Lhs_Tlhs_

Stores the left-hand operand. More...

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Rhs_Trhs_

Stores the right-hand operand. More...

template <class Lhs_T, class Rhs_T, class Epsilon_T>
const boolvalue_ {}

Stores the result of the comparison. More...

Description​

Approximate comparator struct template.

Derived from binary_op, this struct compares two numbers with an explicit tolerance, given as a third operand: the comparison succeeds if the distance between the numbers is at most the tolerance (see detail::differ_by_at_most()). The result is computed at construction time. It is created by the approx (lhs, rhs, epsilon) function comparator, and reported as lhs ~ (rhs +/- epsilon).

The operands may be framework value wrappers or numeric literals, which are unwrapped; their own tolerance, if any, is not used.

Template Parameters
Lhs_T

The type of the stored left-hand operand, either the operand type, or a const reference to it (see stored_operand_t).

Rhs_T

The type of the stored right-hand operand, either the operand type, or a const reference to it.

Epsilon_T

The type of the stored tolerance, either the operand type, or a const reference to it.

Definition at line 1002 of file detail.h.

Public Member Typedefs​

op_type​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
using micro_os_plus::micro_test_plus::detail::op::op_type = op

Marker identifying the framework expression types.

Detected by the extension::is_op concept, and inherited by all types derived from op.

Definition at line 128 of file extension.h.

128 using op_type = op;

Public Constructors​

approx_op()​

template <class L, class R, class E>
micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op (L && lhs, R && rhs, E && epsilon)
constexpr

Constructs an approximate comparator for the given operands.

The result is computed from the arguments, before they are forwarded to the members.

Template Parameters
L

The type of the left-hand operand argument.

R

The type of the right-hand operand argument.

E

The type of the tolerance argument.

Parameters
lhs

The left-hand operand.

rhs

The right-hand operand.

epsilon

The tolerance.

The result is computed from the unwrapped arguments, with detail::differ_by_at_most(), before the operands are forwarded to the base and the tolerance to its member.

Declaration at line 1020 of file detail.h, definition at line 1008 of file detail-inlines.h.

1008 template <class L, class R, class E>
1010 E&& epsilon)
1011 : binary_op<Lhs_T, Rhs_T>{ std::forward<L> (lhs),
1012 std::forward<R> (rhs),
1017 epsilon_{ std::forward<E> (epsilon) }
1018 {

References micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op, micro_os_plus::micro_test_plus::detail::differ_by_at_most, micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon, micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs and micro_os_plus::micro_test_plus::detail::unwrap.

Public Operators​

operator bool()​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::operator bool ()
nodiscard constexpr

Conversion operator to boolean.

Parameters

None.

Returns

The result of the comparison.

Returns the pre-computed boolean result stored by the derived comparator's constructor.

Declaration at line 370 of file detail.h, definition at line 168 of file detail-inlines.h.

168 operator bool () const
169 {
170 return value_;
171 }

References micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op and micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::value_.

Public Member Functions​

epsilon()​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon (void)
nodiscard constexpr

Retrieves the tolerance.

The tolerance is unwrapped with detail::unwrap(), as the operands are.

Parameters

None.

Returns

The extracted tolerance.

Returns the stored tolerance, unwrapped with detail::unwrap().

Declaration at line 1034 of file detail.h, definition at line 1026 of file detail-inlines.h.

1026 constexpr decltype (auto)
1028 {
1029 return detail::unwrap (epsilon_);

References micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon, micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon_ and micro_os_plus::micro_test_plus::detail::unwrap.

Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op and micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon.

lhs()​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs (void)
nodiscard constexpr

rhs()​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs (void)
nodiscard constexpr

Private Member Attributes​

epsilon_​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Epsilon_T micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon_

The stored tolerance.

Stored as the operands are (see stored_operand_t), only to be reported; the result was already computed by the constructor.

Definition at line 1044 of file detail.h.

1044 Epsilon_T epsilon_;

Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon.

lhs_​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Lhs_T micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs_

Stores the left-hand operand.

A value, moved from a temporary or copied from a named operand, or, for a named operand that cannot be copied, a const reference to it (see stored_operand_t). It is not const, so that a temporary expression can be moved into an enclosing one.

Definition at line 410 of file detail.h.

410 Lhs_T lhs_;

Referenced by micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op and micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs.

rhs_​

template <class Lhs_T, class Rhs_T, class Epsilon_T>
Rhs_T micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs_

Stores the right-hand operand.

Stored as the left-hand operand is.

Definition at line 418 of file detail.h.

418 Rhs_T rhs_;

Referenced by micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op and micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs.

value_​

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

Stores the result of the comparison.

Computed once, by the derived comparator constructor.

Definition at line 426 of file detail.h.

426 const bool value_{};

Referenced by micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op and micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::operator bool.


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


Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.