region: remove extent_t/point_t distinction
it's too problematic to retain signedness distinctions between base points and region extents. just use the same types, but retain the named typedefs for compatibility.
This commit is contained in:
parent
ec78216813
commit
9546526c1f
10
region.cpp
10
region.cpp
@ -63,7 +63,7 @@ util::region<S,T>::region (std::array<T,S*2> args)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
typename util::region<S,T>::size_type
|
||||
T
|
||||
util::region<S,T>::area (void) const
|
||||
{
|
||||
return e.area ();
|
||||
@ -72,7 +72,7 @@ util::region<S,T>::area (void) const
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
typename util::region<S,T>::size_type
|
||||
T
|
||||
util::region<S,T>::diameter (void) const
|
||||
{
|
||||
return e.diameter ();
|
||||
@ -101,7 +101,7 @@ util::region<S,T>::magnitude (extent_t _e)
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
void
|
||||
util::region<S,T>::scale (size_type factor)
|
||||
util::region<S,T>::scale (T factor)
|
||||
{
|
||||
auto o = (e * factor - e) / T(2);
|
||||
p -= o;
|
||||
@ -371,8 +371,8 @@ namespace util { namespace debug {
|
||||
struct validator<util::region<S,T>> {
|
||||
static bool is_valid (const util::region<S,T> &r)
|
||||
{
|
||||
CHECK_GE (r.area (), 0u);
|
||||
CHECK_GE (min (r.e), 0u);
|
||||
CHECK_GE (r.area (), T{0});
|
||||
CHECK_GE (min (r.e), T{0});
|
||||
|
||||
return r.area () >= 0 && min (r.e) >= 0;
|
||||
}
|
||||
|
13
region.hpp
13
region.hpp
@ -31,11 +31,8 @@ namespace util {
|
||||
*/
|
||||
template <size_t S, typename T>
|
||||
struct region {
|
||||
using position_type = T;
|
||||
using size_type = typename try_unsigned<T>::type;
|
||||
|
||||
using extent_t = util::extent<S,size_type>;
|
||||
using point_t = util::point<S,position_type>;
|
||||
using extent_t = util::extent<S,T>;
|
||||
using point_t = util::point<S,T>;
|
||||
|
||||
using value_type = T;
|
||||
|
||||
@ -66,12 +63,12 @@ namespace util {
|
||||
constexpr region<S,U> cast (void) const;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
size_type area (void) const;
|
||||
size_type diameter (void) const;
|
||||
T area (void) const;
|
||||
T diameter (void) const;
|
||||
extent_t magnitude (void) const;
|
||||
extent_t magnitude (extent_t);
|
||||
|
||||
void scale (size_type factor);
|
||||
void scale (T factor);
|
||||
|
||||
bool empty (void) const;
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace util {
|
||||
region<S,T>::cast (void) const
|
||||
{
|
||||
return {
|
||||
p.template cast<typename region<S,U>::position_type> (),
|
||||
e.template cast<typename region<S,U>::size_type> ()
|
||||
p.template cast<U> (),
|
||||
e.template cast<U> ()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user