#include "region.hpp" #include "debug.hpp" /* * Rect */ template _rect::_rect (const T _width, const T _height): width (_width), height (_height) { ; } template T _rect::area (void) const { return width * height; } template bool _rect::empty (void) const { return area() == 0; } template bool _rect::operator ==(const _rect& rhs) const { return width == rhs.width && height == rhs.height; } template void _rect::sanity (void) const { check (width >= 0 && height >= 0); } // Replace the check, as unsigned types do not ever go negative. This would // trigger a compile warning if left. template <> void _rect::sanity (void) const { check (true); } template struct _rect; /* * Region */ template _region::_region (T _x, T _y, T _width, T _height): x (_x), y (_y), width (_width), height (_height) { ; } template T _region::area (void) const { return width * height; } template bool _region::empty (void) const { return area () == 0; } template bool _region::operator ==(const _region& rhs) const { return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height; } template void _region::sanity (void) const { check (width >= 0 && height >= 0); }