diff --git a/extent.cpp b/extent.cpp index 444895b5..b12930a4 100644 --- a/extent.cpp +++ b/extent.cpp @@ -136,17 +136,18 @@ util::operator<< (std::ostream &os, util::extent e) } -template std::ostream& util::operator<< (std::ostream&, util::extent<2,uint16_t>); -template std::ostream& util::operator<< (std::ostream&, util::extent<2,uint32_t>); -template std::ostream& util::operator<< (std::ostream&, util::extent<2,uint64_t>); -template std::ostream& util::operator<< (std::ostream&, util::extent<2,float>); -template std::ostream& util::operator<< (std::ostream&, util::extent<2,double>); - - //----------------------------------------------------------------------------- namespace util { - template struct extent<2,uint32_t>; - template struct extent<2,uint64_t>; - template struct extent<2,float>; - template struct extent<2,double>; + #define INSTANTIATE_S_T(S,T) \ + template struct extent; \ + template std::ostream& operator<< (std::ostream&, extent); + + #define INSTANTIATE(T) \ + INSTANTIATE_S_T(2,T) \ + INSTANTIATE_S_T(3,T) + + INSTANTIATE(uint32_t) + INSTANTIATE(uint64_t) + INSTANTIATE(float) + INSTANTIATE(double) } diff --git a/region.cpp b/region.cpp index 2365e702..296b6a1c 100644 --- a/region.cpp +++ b/region.cpp @@ -352,22 +352,8 @@ void util::region::sanity (void) const { CHECK_GE (e.area (), 0); - static_assert(!std::is_floating_point::value, - "Floating point types need width and height checks"); -} - - -//----------------------------------------------------------------------------- -namespace util { - template <> - void region<2,double>::sanity (void) const { - CHECK_GE (e.area (), 0); - } - - - template <> - void region<2,float>::sanity (void) const { - CHECK_GE (e.area (), 0); + if (std::is_floating_point::value) { + CHECK_GE (min (e), 0); } } @@ -404,15 +390,16 @@ util::operator<< (std::ostream &os, const util::region &rhs) { //----------------------------------------------------------------------------- namespace util { - template struct region<2,uint32_t>; - template struct region<2,uint64_t>; - template struct region<2,float>; - template struct region<2,double>; +#define INSTANTIATE_S_T(S,T) \ + template struct region; \ + template std::ostream& operator<< (std::ostream&, const region&); - template std::ostream& operator<< (std::ostream&, const region<2, int32_t>&); - template std::ostream& operator<< (std::ostream&, const region<2, int64_t>&); - template std::ostream& operator<< (std::ostream&, const region<2,uint32_t>&); - template std::ostream& operator<< (std::ostream&, const region<2,uint64_t>&); - template std::ostream& operator<< (std::ostream&, const region<2, float>&); - template std::ostream& operator<< (std::ostream&, const region<2, double>&); +#define INSTANTIATE(T) \ + INSTANTIATE_S_T(2,T) \ + INSTANTIATE_S_T(3,T) + + INSTANTIATE(uint32_t) + INSTANTIATE(uint64_t) + INSTANTIATE(float) + INSTANTIATE(double) }