diff --git a/region.cpp b/region.cpp index a1f4048a..5338afb4 100644 --- a/region.cpp +++ b/region.cpp @@ -29,7 +29,7 @@ using namespace util; template -region::region (T _x, T _y, T _w, T _h): +region::region (T _x, T _y, size_type _w, size_type _h): x (_x), y (_y), w (_w), @@ -49,15 +49,15 @@ region::operator+= (const vector<2> &rhs) { template -T +typename region::size_type region::area (void) const { return w * h; } template -T +typename region::size_type region::diameter (void) const { - return (T)sqrt (w * w + h * h); + return static_cast (sqrt (w * w + h * h)); } diff --git a/region.hpp b/region.hpp index 6d5e84d7..3aa6ce10 100644 --- a/region.hpp +++ b/region.hpp @@ -22,6 +22,7 @@ #define __UTIL_REGION_HPP #include "point.hpp" +#include "types/traits.hpp" namespace util { /** @@ -29,15 +30,17 @@ namespace util { */ template struct region { - T x, y; - T w, h; + typedef typename always_unsigned::type size_type; - region (T _x, T _y, T _w, T _h); + T x, y; + size_type w, h; + + region (T _x, T _y, size_type _w, size_type _h); region& operator +=(const vector<2>& rhs); - T area (void) const; - T diameter (void) const; + size_type area (void) const; + size_type diameter (void) const; bool empty (void) const;