13 #include <type_traits> 36 template <typename Q = T, typename std::enable_if_t<std::is_integral<Q>::value,
int> = 0>
37 static constexpr
bool almostEqual(Q v1, Q v2)
42 template <typename Q = T, typename std::enable_if_t<std::is_floating_point<Q>::value,
int> = 0>
43 static constexpr Q almostEqualMaxHelper(Q v1, Q v2)
45 return std::max<Q>({ 1.0, std::fabs(v1), std::fabs(v2) });
48 template <typename Q = T, typename std::enable_if_t<std::is_floating_point<Q>::value,
int> = 0>
49 static constexpr
bool almostEqual(Q v1, Q v2)
51 return std::fabs(v1 - v2) <= std::numeric_limits<Q>::epsilon() * almostEqualMaxHelper(v1, v2);
54 template <typename Q = T, typename std::enable_if_t<std::is_integral<Q>::value,
int> = 0>
55 constexpr
bool validateInc(Q v)
const 57 if (m_inc != 0 && (v % m_inc) != 0)
64 template <typename Q = T, typename std::enable_if_t<std::is_floating_point<Q>::value,
int> = 0>
65 constexpr
bool validateInc(Q v)
const 67 if (!almostEqual<Q>(m_inc, 0) && !almostEqual<Q>(std::fmod(v, m_inc), 0))
84 constexpr
Range(T min, T max, T inc)
101 if (almostEqual(min, max))
156 if (value < m_min || value > m_max)
161 return validateInc<T>(value);
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_NO_DISCARD constexpr T Maximum() const
Get the maximum value for the range.
Definition: peak_ipl_range.hpp:122
The exception thrown when passing an invalid parameter to a function.
Definition: peak_ipl_exception.hpp:58
constexpr Range(T min, T max, T inc)
Constructor for the Range.
Definition: peak_ipl_range.hpp:84
PEAK_IPL_NO_DISCARD constexpr T Increment() const
Get the increment value for the range.
Definition: peak_ipl_range.hpp:132
PEAK_IPL_NO_DISCARD constexpr T Minimum() const
Get the minimum value for the range.
Definition: peak_ipl_range.hpp:112
Range support and convenience class.
Definition: peak_ipl_range.hpp:30
PEAK_IPL_NO_DISCARD constexpr std::tuple< T, T, T > GetRange() const
Get the range as tuple.
Definition: peak_ipl_range.hpp:142
PEAK_IPL_NO_DISCARD constexpr bool InRange(T value) const
Check if the value is in range.
Definition: peak_ipl_range.hpp:154