342 template <
typename TFloatType1,
typename TFloatType2>
349 template <
typename TFloatType1,
typename TFloatType2>
356 template <
typename TFloatType1,
typename TFloatType2>
363 template <
typename TFloatType1,
typename TFloatType2>
370 template <
typename TFloatType1,
typename TFloatType2>
380 template <
typename TFloatType,
typename TIntType>
390 template <
typename TIntType,
typename TFloatType>
400 template <
typename TSignedInt,
typename TUn
signedInt>
404 if (signedVariable < 0)
412 return signedVariable ==
static_cast<TSignedInt
>(unsignedVariable);
418 template <
typename TUn
signedInt,
typename TSignedInt>
428 template <
typename TIntegerType1,
typename TIntegerType2>
439template <
bool TInput1IsIntger,
bool TInput1IsSigned,
bool TInput2IsInteger,
bool TInput2IsSigned>
454struct AlmostEqualsFunctionSelector<false, true, true, true>
461struct AlmostEqualsFunctionSelector<false, true, true, false>
468struct AlmostEqualsFunctionSelector<true, false, false, true>
511template <
typename TInputType1,
typename TInputType2>
512struct AlmostEqualsScalarImplementer
514 static constexpr bool TInputType1IsInteger = std::is_integral_v<TInputType1>;
515 static constexpr bool TInputType1IsSigned = std::is_signed_v<TInputType1>;
516 static constexpr bool TInputType2IsInteger = std::is_integral_v<TInputType2>;
517 static constexpr bool TInputType2IsSigned = std::is_signed_v<TInputType2>;
519 using SelectedVersion =
typename AlmostEqualsFunctionSelector<TInputType1IsInteger,
521 TInputType2IsInteger,
522 TInputType2IsSigned>::SelectedVersion;
528template <
typename TScalarType1,
typename TScalarType2>
530AlmostEqualsScalarComparer(TScalarType1 x1, TScalarType2 x2)
532 return AlmostEqualsScalarImplementer<TScalarType1, TScalarType2>::SelectedVersion::
533 template AlmostEqualsFunction<TScalarType1, TScalarType2>(x1, x2);
540struct AlmostEqualsScalarVsScalar
542 template <
typename TScalarType1,
typename TScalarType2>
544 AlmostEqualsFunction(TScalarType1 x1, TScalarType2 x2)
546 return AlmostEqualsScalarComparer(x1, x2);
552struct AlmostEqualsComplexVsComplex
554 template <
typename TComplexType1,
typename TComplexType2>
556 AlmostEqualsFunction(TComplexType1 x1, TComplexType2 x2)
558 return AlmostEqualsScalarComparer(x1.real(), x2.real()) && AlmostEqualsScalarComparer(x1.imag(), x2.imag());
565struct AlmostEqualsScalarVsComplex
567 template <
typename TScalarType,
typename TComplexType>
569 AlmostEqualsFunction(TScalarType scalarVariable, TComplexType complexVariable)
575 return AlmostEqualsScalarComparer(scalarVariable, complexVariable.real());
579struct AlmostEqualsComplexVsScalar
581 template <
typename TComplexType,
typename TScalarType>
583 AlmostEqualsFunction(TComplexType complexVariable, TScalarType scalarVariable)
585 return AlmostEqualsScalarVsComplex::AlmostEqualsFunction(scalarVariable, complexVariable);
592template <
bool T1IsComplex,
bool T2IsComplex>
593struct AlmostEqualsComplexChooser
595 using ChosenVersion = AlmostEqualsScalarVsScalar;
599struct AlmostEqualsComplexChooser<true, true>
601 using ChosenVersion = AlmostEqualsComplexVsComplex;
605struct AlmostEqualsComplexChooser<false, true>
607 using ChosenVersion = AlmostEqualsScalarVsComplex;
611struct AlmostEqualsComplexChooser<true, false>
613 using ChosenVersion = AlmostEqualsComplexVsScalar;
621template <
typename T1,
typename T2>
622struct AlmostEqualsComplexImplementer
624 static constexpr bool T1IsComplex = NumericTraits<T1>::IsComplex;
625 static constexpr bool T2IsComplex = NumericTraits<T2>::IsComplex;
627 using ChosenVersion =
typename AlmostEqualsComplexChooser<T1IsComplex, T2IsComplex>::ChosenVersion;