346 template <
typename TFloatType1,
typename TFloatType2>
353 template <
typename TFloatType1,
typename TFloatType2>
360 template <
typename TFloatType1,
typename TFloatType2>
367 template <
typename TFloatType1,
typename TFloatType2>
374 template <
typename TFloatType1,
typename TFloatType2>
384 template <
typename TFloatType,
typename TIntType>
394 template <
typename TIntType,
typename TFloatType>
404 template <
typename TSignedInt,
typename TUn
signedInt>
408 if (signedVariable < 0)
416 return signedVariable ==
static_cast<TSignedInt
>(unsignedVariable);
422 template <
typename TUn
signedInt,
typename TSignedInt>
432 template <
typename TIntegerType1,
typename TIntegerType2>
443template <
bool TInput1IsIntger,
bool TInput1IsSigned,
bool TInput2IsInteger,
bool TInput2IsSigned>
458struct AlmostEqualsFunctionSelector<false, true, true, true>
465struct AlmostEqualsFunctionSelector<false, true, true, false>
472struct AlmostEqualsFunctionSelector<true, false, false, true>
515template <
typename TInputType1,
typename TInputType2>
516struct AlmostEqualsScalarImplementer
518 static constexpr bool TInputType1IsInteger = std::is_integral_v<TInputType1>;
519 static constexpr bool TInputType1IsSigned = std::is_signed_v<TInputType1>;
520 static constexpr bool TInputType2IsInteger = std::is_integral_v<TInputType2>;
521 static constexpr bool TInputType2IsSigned = std::is_signed_v<TInputType2>;
523 using SelectedVersion =
typename AlmostEqualsFunctionSelector<TInputType1IsInteger,
525 TInputType2IsInteger,
526 TInputType2IsSigned>::SelectedVersion;
532template <
typename TScalarType1,
typename TScalarType2>
534AlmostEqualsScalarComparer(TScalarType1 x1, TScalarType2 x2)
536 return AlmostEqualsScalarImplementer<TScalarType1, TScalarType2>::SelectedVersion::
537 template AlmostEqualsFunction<TScalarType1, TScalarType2>(x1, x2);
544struct AlmostEqualsScalarVsScalar
546 template <
typename TScalarType1,
typename TScalarType2>
548 AlmostEqualsFunction(TScalarType1 x1, TScalarType2 x2)
550 return AlmostEqualsScalarComparer(x1, x2);
556struct AlmostEqualsComplexVsComplex
558 template <
typename TComplexType1,
typename TComplexType2>
560 AlmostEqualsFunction(TComplexType1 x1, TComplexType2 x2)
562 return AlmostEqualsScalarComparer(x1.real(), x2.real()) && AlmostEqualsScalarComparer(x1.imag(), x2.imag());
569struct AlmostEqualsScalarVsComplex
571 template <
typename TScalarType,
typename TComplexType>
573 AlmostEqualsFunction(TScalarType scalarVariable, TComplexType complexVariable)
579 return AlmostEqualsScalarComparer(scalarVariable, complexVariable.real());
583struct AlmostEqualsComplexVsScalar
585 template <
typename TComplexType,
typename TScalarType>
587 AlmostEqualsFunction(TComplexType complexVariable, TScalarType scalarVariable)
589 return AlmostEqualsScalarVsComplex::AlmostEqualsFunction(scalarVariable, complexVariable);
596template <
bool T1IsComplex,
bool T2IsComplex>
597struct AlmostEqualsComplexChooser
599 using ChosenVersion = AlmostEqualsScalarVsScalar;
603struct AlmostEqualsComplexChooser<true, true>
605 using ChosenVersion = AlmostEqualsComplexVsComplex;
609struct AlmostEqualsComplexChooser<false, true>
611 using ChosenVersion = AlmostEqualsScalarVsComplex;
615struct AlmostEqualsComplexChooser<true, false>
617 using ChosenVersion = AlmostEqualsComplexVsScalar;
625template <
typename T1,
typename T2>
626struct AlmostEqualsComplexImplementer
628 static constexpr bool T1IsComplex = NumericTraits<T1>::IsComplex;
629 static constexpr bool T2IsComplex = NumericTraits<T2>::IsComplex;
631 using ChosenVersion =
typename AlmostEqualsComplexChooser<T1IsComplex, T2IsComplex>::ChosenVersion;