43 static_assert(std::is_arithmetic<T>::value,
"Template argument of Interval must be arithmetic.");
59 constexpr RangeT(T minimum, T maximum, T increment)
61 , m_increment{ increment }
63 if (increment > maximum - minimum)
98 if (!IsIncrementEqualToZero<T>() && value > minimum)
100 value = RoundToIncrement(value);
131 return !(rhs == *
this);
156 std::ostringstream ss;
164 friend detail::BackendAccessor<RangeT<T>>;
166 template <
typename U = T,
typename std::enable_if<has_c_type_of<RangeT<U>>::value,
bool>::type = false>
168 :
RangeT<U>(range.minimum, range.maximum, range.increment)
171 template <
typename U = T,
typename std::enable_if<has_c_type_of<RangeT<U>>::value,
bool>::type = false>
172 constexpr explicit operator detail::c_type_of_t<RangeT<U>>()
const
177 template <typename V = T, std::enable_if_t<std::is_integral<V>::value,
int> = 0>
180 return m_increment == 0;
183 template <typename V = T, std::enable_if_t<std::is_floating_point<V>::value,
int> = 0>
187 constexpr uint32_t ulp = 4;
191 template<typename V = T, std::enable_if_t<std::is_integral<V>::value,
int> = 0>
195 const auto step = (offset + m_increment / 2) / m_increment;
199 template<typename V = T, std::enable_if_t<std::is_floating_point<V>::value,
int> = 0>
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:53
Represents a continuous numeric interval with inclusive lower and upper bounds.
Definition peak_common_interval.hpp:39
constexpr IntervalT(uint32_t minimum, uint32_t maximum)
Definition peak_common_interval.hpp:56
PEAK_COMMON_NO_DISCARD constexpr T GetMaximum() const
Returns the upper boundary of the interval.
Definition peak_common_interval.hpp:83
constexpr bool operator==(const IntervalT< H > &rhs) const
Compares two intervals for equality (integral types).
Definition peak_common_interval.hpp:121
PEAK_COMMON_NO_DISCARD constexpr T GetMinimum() const
Returns the lower boundary of the interval.
Definition peak_common_interval.hpp:72
Represents a numeric range with defined boundaries and a fixed increment.
Definition peak_common_range.hpp:40
PEAK_COMMON_NO_DISCARD constexpr T Constrain(T value) const
Returns a value that is constrained to this range.
Definition peak_common_range.hpp:93
constexpr bool operator==(const RangeT &rhs) const
Compares this range with another for equality.
Definition peak_common_range.hpp:116
constexpr RangeT(T minimum, T maximum, T increment)
Constructs a range with specified minimum, maximum, and increment values.
Definition peak_common_range.hpp:59
T type
Definition peak_common_range.hpp:45
PEAK_COMMON_NO_DISCARD constexpr T GetIncrement() const
Retrieves the increment value associated with this range.
Definition peak_common_range.hpp:76
constexpr bool operator!=(const RangeT &rhs) const
Compares this range with another for inequality.
Definition peak_common_range.hpp:129
PEAK_COMMON_NO_DISCARD std::string ToString() const
Returns a string representation of the range.
Definition peak_common_range.hpp:154
friend std::ostream & operator<<(std::ostream &os, RangeT range)
Outputs the range as a human-readable string to a stream.
Definition peak_common_range.hpp:142
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:45
detail::RangeT< uint32_t > RangeU
Alias for a range of 32-bit unsigned integers.
Definition peak_common_range.hpp:222
detail::RangeT< double > RangeD
Alias for a range of double-precision floating-point numbers.
Definition peak_common_range.hpp:282
detail::RangeT< int32_t > Range
Alias for a range of 32-bit signed integers.
Definition peak_common_range.hpp:237
detail::RangeT< int64_t > Range64
Alias for a range of 64-bit signed integers.
Definition peak_common_range.hpp:252
detail::RangeT< uint8_t > RangeU8
Alias for a range of 8-bit unsigned integers.
Definition peak_common_range.hpp:297
detail::RangeT< float > RangeF
Alias for a range of floating-point numbers.
Definition peak_common_range.hpp:267
Namespace for internal implementation details and low-level types.
Definition peak_common_math.hpp:19
constexpr T Clamp(T value, T minimum, T maximum)
Definition peak_common_math.hpp:51
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:17
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89