region: try to use unsigned types for extent
This commit is contained in:
parent
93ec5be1f3
commit
6bd9ad333c
@ -335,8 +335,6 @@ util::operator<< (std::ostream &os, const util::region<T> &rhs) {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace util {
|
||||
template struct region<int32_t>;
|
||||
template struct region<int64_t>;
|
||||
template struct region<uint32_t>;
|
||||
template struct region<uint64_t>;
|
||||
template struct region<float>;
|
||||
|
@ -31,8 +31,8 @@ namespace util {
|
||||
*/
|
||||
template <typename T>
|
||||
struct region {
|
||||
typedef T position_type;
|
||||
typedef T size_type;
|
||||
using position_type = T;
|
||||
using size_type = typename try_unsigned<T>::type;
|
||||
|
||||
static constexpr size_t dimension = 2u;
|
||||
static constexpr size_t elements = dimension * 2;
|
||||
|
@ -21,13 +21,13 @@ main (int, char **) {
|
||||
CHECK_EQ (region<double>::UNIT.area (), 1.0);
|
||||
CHECK_EQ (region< float>::UNIT.area (), 1.0f);
|
||||
|
||||
CHECK (region<int> (0, 0, 2, 2).includes (point<2,int>(1, 1)));
|
||||
CHECK (region<int> (0, 0, 2, 2).includes (point<2,int>(0, 0)));
|
||||
CHECK (region<int> (0, 0, 2, 2).includes (point<2,int>(2, 2)));
|
||||
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(1, 1)));
|
||||
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(0, 0)));
|
||||
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(2, 2)));
|
||||
|
||||
CHECK ( region<int> (0, 0, 2, 2).contains (point<2,int>(1, 1)));
|
||||
CHECK (!region<int> (0, 0, 2, 2).contains (point<2,int>(0, 0)));
|
||||
CHECK (!region<int> (0, 0, 2, 2).contains (point<2,int>(2, 2)));
|
||||
CHECK ( region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(1, 1)));
|
||||
CHECK (!region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(0, 0)));
|
||||
CHECK (!region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(2, 2)));
|
||||
|
||||
//CHECK (region<intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
|
||||
//CHECK (region<intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
|
||||
|
Loading…
Reference in New Issue
Block a user