From ba878238afc74df252bb4eaac7538fb656555433 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 20 Feb 2015 15:26:59 +1100 Subject: [PATCH] region: add vector addition operator --- region.cpp | 12 +++++++++++- region.hpp | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/region.cpp b/region.cpp index 62ad34cb..5767270d 100644 --- a/region.cpp +++ b/region.cpp @@ -297,7 +297,17 @@ util::region::expanded (T mag) const return expanded (mag, mag); } -//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +template +util::region +util::region::operator+ (vector<2,T> rhs) const +{ + return { x + rhs.x, y + rhs.y, w, h }; +} + + +/////////////////////////////////////////////////////////////////////////////// template bool util::region::operator== (const region& rhs) const diff --git a/region.hpp b/region.hpp index 281d2ed5..3bf839f9 100644 --- a/region.hpp +++ b/region.hpp @@ -23,6 +23,7 @@ #include "extent.hpp" #include "point.hpp" +#include "vector.hpp" #include "types/traits.hpp" namespace util { @@ -80,6 +81,9 @@ namespace util { region& expand (T mag); region& expand (T w, T h); + // arithmetic operators + region operator+ (vector<2,T>) const; + // Logical comparison operators bool operator ==(const region& rhs) const; bool operator !=(const region& rhs) const