commit 1162d24a197340aaab3a1dff317a6374c73ec495
parent 0d6f63e9b284207efe27e798ccdfbb307ee56302
Author: falkTX <falktx@falktx.com>
Date: Sun, 30 May 2021 21:37:08 +0100
Add extra multiplier and divider operator to Size
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/dgl/Geometry.hpp b/dgl/Geometry.hpp
@@ -219,6 +219,8 @@ public:
Size<T>& operator-=(const Size<T>& size) noexcept;
Size<T>& operator*=(double m) noexcept;
Size<T>& operator/=(double d) noexcept;
+ Size<T> operator*(double m) const noexcept;
+ Size<T> operator/(double m) const noexcept;
bool operator==(const Size<T>& size) const noexcept;
bool operator!=(const Size<T>& size) const noexcept;
diff --git a/dgl/src/Geometry.cpp b/dgl/src/Geometry.cpp
@@ -325,6 +325,22 @@ Size<T>& Size<T>::operator/=(double d) noexcept
}
template<typename T>
+Size<T> Size<T>::operator*(const double m) const noexcept
+{
+ Size<T> size(fWidth, fHeight);
+ size *= m;
+ return size;
+}
+
+template<typename T>
+Size<T> Size<T>::operator/(const double m) const noexcept
+{
+ Size<T> size(fWidth, fHeight);
+ size /= m;
+ return size;
+}
+
+template<typename T>
bool Size<T>::operator==(const Size<T>& size) const noexcept
{
return (fWidth == size.fWidth && fHeight == size.fHeight);