#pragma once #include #include #include template inline bool isNaN(T x) { /// To be sure, that this function is zero-cost for non-floating point types. if constexpr (std::is_floating_point_v) return std::isnan(x); else return false; } template inline bool isFinite(T x) { if constexpr (std::is_floating_point_v) return std::isfinite(x); else return true; } template T NaNOrZero() { if constexpr (std::is_floating_point_v) return std::numeric_limits::quiet_NaN(); else return {}; }