45 static_assert(std::is_arithmetic<T>::value,
"Template argument of Size must be arithmetic.");
66 template <
typename H = T
69 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
72 constexpr SizeT(T width, T height)
76 static_assert(std::is_unsigned<T>::value,
"Parameter width and/or height has to be greater or equal to zero.");
92 template <
typename H = T
95 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
98 constexpr SizeT(T width, T height)
145 return { m_height, m_width };
161 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
182 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
188 constexpr uint32_t ulp = 4;
190 using common_type = std::common_type_t<H, T>;
206 template <
typename H>
209 return !(*
this == rhs);
225 return os <<
"{ width: " << size.
GetWidth() <<
", height: " << size.
GetHeight() <<
" }";
239 std::ostringstream ss;
248 friend detail::BackendAccessor<SizeT<T>>;
250 template <
typename U = T,
typename std::enable_if<has_c_type_of<SizeT<U>>::value,
bool>::type = false>
251 constexpr explicit operator detail::c_type_of_t<SizeT<T>>()
const
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:58
Represents a two-dimensional size with non-negative width and height.
Definition peak_common_size.hpp:42
PEAK_COMMON_NO_DISCARD constexpr T GetWidth() const
Returns the width.
Definition peak_common_size.hpp:119
constexpr SizeT(T width, T height)
Constructs a SizeT object from integral width and height.
Definition peak_common_size.hpp:72
PEAK_COMMON_NO_DISCARD constexpr T GetHeight() const
Returns the height.
Definition peak_common_size.hpp:131
constexpr bool operator!=(const SizeT< H > &rhs) const
Inequality operator.
Definition peak_common_size.hpp:207
constexpr SizeT()=default
Default constructor for SizeT.
PEAK_COMMON_NO_DISCARD std::string ToString() const
Convert the SizeT instance to a string representation.
Definition peak_common_size.hpp:237
constexpr bool operator==(const SizeT< H > &rhs) const
Equality operator for integral types.
Definition peak_common_size.hpp:164
PEAK_COMMON_NO_DISCARD constexpr SizeT< T > Transposed() const
Returns a transposed size with width and height swapped.
Definition peak_common_size.hpp:143
friend std::ostream & operator<<(std::ostream &os, SizeT size)
Stream operator to output SizeT in a readable format.
Definition peak_common_size.hpp:223
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::SizeT< float > SizeF
Size with floating-point dimensions.
Definition peak_common_size.hpp:289
detail::SizeT< uint32_t > Size
Size with unsigned 32-bit integer dimensions.
Definition peak_common_size.hpp:273
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
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:94