[Utilities] Fixed area_base operator* scalar type

This commit is contained in:
DH 2021-11-28 09:19:44 +02:00 committed by Nekotekina
parent 02832d9623
commit 813c3298ad

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <type_traits>
template<typename T> template<typename T>
struct size2_base struct size2_base
@ -670,17 +671,22 @@ struct area_base
{ {
return{ x1 / size.width, y1 / size.height, x2 / size.width, y2 / size.height }; return{ x1 / size.width, y1 / size.height, x2 / size.width, y2 / size.height };
} }
constexpr area_base operator / (const T& value) const
template <typename U> requires (std::is_arithmetic_v<U>)
constexpr area_base operator / (const U& value) const
{ {
return{ x1 / value, y1 / value, x2 / value, y2 / value }; return area_base{static_cast<T>(x1 / value), static_cast<T>(y1 / value), static_cast<T>(x2 / value), static_cast<T>(y2 / value)};
} }
constexpr area_base operator * (const size2_base<T>& size) const constexpr area_base operator * (const size2_base<T>& size) const
{ {
return{ x1 * size.width, y1 * size.height, x2 * size.width, y2 * size.height }; return{ x1 * size.width, y1 * size.height, x2 * size.width, y2 * size.height };
} }
constexpr area_base operator * (const f32& value) const
template <typename U> requires (std::is_arithmetic_v<U>)
constexpr area_base operator * (const U& value) const
{ {
return{ static_cast<T>(x1 * value), static_cast<T>(y1 * value), static_cast<T>(x2 * value), static_cast<T>(y2 * value) }; return area_base{static_cast<T>(x1 * value), static_cast<T>(y1 * value), static_cast<T>(x2 * value), static_cast<T>(y2 * value)};
} }
template<typename NT> template<typename NT>