point: add is_valid specialisation

This commit is contained in:
Danny Robson 2016-10-25 19:58:19 +11:00
parent 919c635f63
commit 7121415c5f

View File

@ -48,23 +48,27 @@ util::point<S,T>::from (point<S,T> rhs) const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T> namespace util::debug {
void template <size_t S, typename T>
util::point<S,T>::sanity (void) const struct validator<point<S,T>> {
{ static bool is_valid (const point<S,T> &p)
CHECK (std::all_of (this->begin (), {
this->end (), // ensure we don't have a nan anywhere
[] (auto i) { return !std::isnan (i); })); return std::all_of (p.cbegin (), p.cend (), [] (auto i) {
return !(std::is_floating_point<T>::value && std::isnan (i));
});
}
};
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <size_t S, typename T> template <size_t S, typename T>
const util::point<S,T> util::point<S,T>::ORIGIN (T {0}); const util::point<S,T> util::point<S,T>::ORIGIN (T {0});
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define INSTANTIATE_S_T(S,T) \ #define INSTANTIATE_S_T(S,T) \
template struct util::point<S,T>; template struct util::point<S,T>; \
template bool util::debug::is_valid (const point<S,T>&);
#define INSTANTIATE(T) \ #define INSTANTIATE(T) \
INSTANTIATE_S_T(1,T) \ INSTANTIATE_S_T(1,T) \