47 static_assert(std::is_arithmetic<T>::value,
"Template argument of Interval must be arithmetic.");
65 if (minimum > maximum)
106 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
128 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
134 constexpr uint32_t ulp = 4;
136 using common_type = std::common_type_t<H, T>;
151 return !(rhs == *
this);
164 return os <<
"{ minimum: " << interval.m_minimum <<
", maximum: " << interval.m_maximum <<
" }";
175 std::ostringstream ss;
184 friend detail::BackendAccessor<IntervalT<T>>;
186 template <
typename U = T,
typename std::enable_if<has_c_type_of<IntervalT<U>>::value,
bool>::type = false>
188 :
IntervalT<U>(interval.minimum, interval.maximum)
191 template <
typename U = T,
typename std::enable_if<has_c_type_of<IntervalT<U>>::value,
bool>::type = false>
192 constexpr explicit operator detail::c_type_of_t<IntervalT<U>>()
const
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:58
Represents a continuous numeric interval with inclusive lower and upper bounds.
Definition peak_common_interval.hpp:44
friend std::ostream & operator<<(std::ostream &os, IntervalT interval)
Outputs the interval as a human-readable string to a stream.
Definition peak_common_interval.hpp:162
constexpr IntervalT(T minimum, T maximum)
Constructs an interval with the given lower and upper bounds.
Definition peak_common_interval.hpp:61
PEAK_COMMON_NO_DISCARD constexpr T GetMaximum() const
Returns the upper boundary of the interval.
Definition peak_common_interval.hpp:88
PEAK_COMMON_NO_DISCARD std::string ToString() const
Returns a string representation of the interval.
Definition peak_common_interval.hpp:173
constexpr bool operator==(const IntervalT< H > &rhs) const
Compares two intervals for equality (integral types).
Definition peak_common_interval.hpp:109
T type
Definition peak_common_interval.hpp:49
constexpr bool operator!=(const IntervalT &rhs) const
Inequality comparison operator.
Definition peak_common_interval.hpp:149
PEAK_COMMON_NO_DISCARD constexpr T GetMinimum() const
Returns the lower boundary of the interval.
Definition peak_common_interval.hpp:77
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
Definition peak_common_defines.h:86
constexpr bool AreAlmostEqual(H lhs, H rhs, uint32_t ulp)
Compares two floating-point values for approximate equality using a ULP-based tolerance.
Definition peak_common_math.hpp:50
detail::IntervalT< float > IntervalF
Interval with floating-point boundaries.
Definition peak_common_interval.hpp:246
detail::IntervalT< int32_t > Interval
Interval with signed 32-bit integer boundaries.
Definition peak_common_interval.hpp:230
detail::IntervalT< uint32_t > IntervalU
Interval with unsigned 32-bit integer boundaries.
Definition peak_common_interval.hpp:214
Namespace for internal implementation details and low-level types.
Definition peak_common_math.hpp:24
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:22