From c85f1cde101d5c6c8912c1131d4d43a828d87015 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 14 Sep 2012 22:21:56 +0200 Subject: utils/dimension: add == and != operators --- src/utils/dimension.hpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/utils') diff --git a/src/utils/dimension.hpp b/src/utils/dimension.hpp index 95fc8204..85799c38 100644 --- a/src/utils/dimension.hpp +++ b/src/utils/dimension.hpp @@ -40,20 +40,23 @@ namespace usdx { } - Dimension(const Dimension& dimension) : - width(dimension.width), height(dimension.height) + /** + * Two dimensions are equal, if width and height are equal. + */ + bool operator==(const Dimension &other) const { + return (width == other.width) && (height == other.height); } - Dimension& operator=(const Dimension& dimension) + /** + * Two dimensions are different, if either width or height are different. + */ + bool operator!=(const Dimension &other) const { - width = dimension.width; - height = dimension.height; - return *this; + // they are different, if they are not equal + return !(*this == other); } - - T get_width(void) const { return width; -- cgit v1.2.3