Make width/height unsigned where possible
This commit is contained in:
parent
4899f08772
commit
45a1b6b93c
@ -29,7 +29,7 @@ using namespace util;
|
|||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
region<T>::region (T _x, T _y, T _w, T _h):
|
region<T>::region (T _x, T _y, size_type _w, size_type _h):
|
||||||
x (_x),
|
x (_x),
|
||||||
y (_y),
|
y (_y),
|
||||||
w (_w),
|
w (_w),
|
||||||
@ -49,15 +49,15 @@ region<T>::operator+= (const vector<2> &rhs) {
|
|||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T
|
typename region<T>::size_type
|
||||||
region<T>::area (void) const
|
region<T>::area (void) const
|
||||||
{ return w * h; }
|
{ return w * h; }
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T
|
typename region<T>::size_type
|
||||||
region<T>::diameter (void) const {
|
region<T>::diameter (void) const {
|
||||||
return (T)sqrt (w * w + h * h);
|
return static_cast<size_type> (sqrt (w * w + h * h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
13
region.hpp
13
region.hpp
@ -22,6 +22,7 @@
|
|||||||
#define __UTIL_REGION_HPP
|
#define __UTIL_REGION_HPP
|
||||||
|
|
||||||
#include "point.hpp"
|
#include "point.hpp"
|
||||||
|
#include "types/traits.hpp"
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
/**
|
/**
|
||||||
@ -29,15 +30,17 @@ namespace util {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct region {
|
struct region {
|
||||||
T x, y;
|
typedef typename always_unsigned<T>::type size_type;
|
||||||
T w, h;
|
|
||||||
|
|
||||||
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);
|
region& operator +=(const vector<2>& rhs);
|
||||||
|
|
||||||
T area (void) const;
|
size_type area (void) const;
|
||||||
T diameter (void) const;
|
size_type diameter (void) const;
|
||||||
|
|
||||||
bool empty (void) const;
|
bool empty (void) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user