18#include <peak_common_c/types/peak_common_simple_types.h>
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>
Thrown when a function receives an invalid parameter.
Represents a continuous numeric interval with inclusive lower and upper bounds.
friend std::ostream & operator<<(std::ostream &os, IntervalT interval)
Outputs the interval as a human-readable string to a stream.
constexpr T GetMinimum() const
Returns the lower boundary of the interval.
std::string ToString() const
Returns a string representation of the interval.
constexpr IntervalT(T minimum, T maximum)
Constructs an interval with the given lower and upper bounds.
constexpr bool operator==(const IntervalT< H > &rhs) const
Compares two intervals for equality (integral types).
constexpr T GetMaximum() const
Returns the upper boundary of the interval.
constexpr bool operator!=(const IntervalT &rhs) const
Inequality comparison operator.
constexpr bool AreAlmostEqual(H lhs, H rhs, uint32_t ulp)
Compares two floating-point values for approximate equality using a ULP-based tolerance.
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
typename c_type_of_< Type >::type c_type_of_t