40 static_assert(std::is_arithmetic<T>::value,
"Template argument of Size must be arithmetic.");
61 template <
typename H = T
64 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
67 constexpr SizeT(T width, T height)
71 static_assert(std::is_unsigned<T>::value,
"Parameter width and/or height has to be greater or equal to zero.");
87 template <
typename H = T
90 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
93 constexpr SizeT(T width, T height)
114 PEAK_COMMON_NO_DISCARD
constexpr T
GetWidth()
const
140 return { m_height, m_width };
156 typename std::enable_if_t<std::is_integral<H>::value,
int> = 0
177 typename std::enable_if_t<std::is_floating_point<H>::value,
int> = 0
183 constexpr uint32_t ulp = 4;
185 using common_type = std::common_type_t<H, T>;
201 template <
typename H>
204 return !(*
this == rhs);
220 return os <<
"{ width: " << size.
GetWidth() <<
", height: " << size.
GetHeight() <<
" }";
232 PEAK_COMMON_NO_DISCARD std::string
ToString()
const
234 std::ostringstream ss;
243 friend detail::BackendAccessor<SizeT<T>>;
245 template <
typename U = T,
typename std::enable_if<has_c_type_of<SizeT<U>>::value,
bool>::type = false>
246 constexpr explicit operator detail::c_type_of_t<SizeT<T>>()
const
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:53
Represents a two-dimensional size with non-negative width and height.
Definition peak_common_size.hpp:37
std::string ToString() const
Convert the SizeT instance to a string representation.
Definition peak_common_size.hpp:232
constexpr T GetWidth() const
Returns the width.
Definition peak_common_size.hpp:114
constexpr T GetHeight() const
Returns the height.
Definition peak_common_size.hpp:126
constexpr bool operator!=(const SizeT< H > &rhs) const
Inequality operator.
Definition peak_common_size.hpp:202
friend std::ostream & operator<<(std::ostream &os, SizeT size)
Stream operator to output SizeT in a readable format.
Definition peak_common_size.hpp:218
constexpr SizeT< T > Transposed() const
Returns a transposed size with width and height swapped.
Definition peak_common_size.hpp:138
constexpr SizeT()=default
Default constructor for SizeT.
constexpr bool operator==(const SizeT< H > &rhs) const
Equality operator for integral types.
Definition peak_common_size.hpp:159
constexpr SizeT(T width, T height)
Constructs a SizeT object from integral width and height.
Definition peak_common_size.hpp:67
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::SizeT< float > SizeF
Size with floating-point dimensions.
Definition peak_common_size.hpp:284
detail::SizeT< uint32_t > Size
Size with unsigned 32-bit integer dimensions.
Definition peak_common_size.hpp:268
Namespace for internal implementation details and low-level types.
Definition peak_common_math.hpp:19
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:17