diff --git a/Makefile.am b/Makefile.am index 8e91d76b..806f23a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,5 +77,5 @@ SUFFIXES = .cpp .cpp.rl lib_LTLIBRARIES = libutil.la libutil_la_SOURCES = $(UTIL_INCLUDE) $(UTIL_FILES) -libutil_la_CXXFLAGS = -fPIC $(AM_CXXFLAGS) +libutil_la_CXXFLAGS = -fPIC $(AM_CXXFLAGS) -lrt libutil_la_LIBADD = $(BOOST_SYSTEM_LIB) diff --git a/region.cpp b/region.cpp index 4f541147..b6b89830 100644 --- a/region.cpp +++ b/region.cpp @@ -70,7 +70,6 @@ namespace util { { return; } } - template struct extent; template struct extent; @@ -79,7 +78,7 @@ template struct extent; */ template -_region::_region (T _x, T _y, T _width, T _height): +region::region (T _x, T _y, T _width, T _height): x (_x), y (_y), width (_width), @@ -89,25 +88,37 @@ _region::_region (T _x, T _y, T _width, T _height): template T -_region::area (void) const +region::area (void) const { return width * height; } template bool -_region::empty (void) const - { return area () == 0; } +region::empty (void) const + { return almost_equal (area (), 0); } template bool -_region::operator ==(const _region& rhs) const - { return x == rhs.x && - y == rhs.y && - width == rhs.width && - height == rhs.height; } +region::operator ==(const region& rhs) const + { return almost_equal (x, rhs.x) && + almost_equal (y, rhs.y) && + almost_equal (width, rhs.width) && + almost_equal (height, rhs.height); } template -void _region::sanity (void) const +void region::sanity (void) const { check (width >= 0 && height >= 0); } + + +namespace util { + template <> + void region::sanity (void) const + { return; } +} + + +template struct region; +template struct region; + diff --git a/region.hpp b/region.hpp index cac99eeb..fd112210 100644 --- a/region.hpp +++ b/region.hpp @@ -46,23 +46,21 @@ namespace util { * A two-dimensional rectangle, with size and position. */ template - struct _region { + struct region { T x, y; T width, height; - _region (T _x, T _y, T _width, T _height); + region (T _x, T _y, T _width, T _height); T area (void) const; bool empty (void) const; - bool operator ==(const _region& rhs) const; - bool operator !=(const _region& rhs) const + bool operator ==(const region& rhs) const; + bool operator !=(const region& rhs) const { return !(*this == rhs); } void sanity (void) const; }; - - typedef _region region; } #endif