diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 2a487deb4..c21eb5281 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -643,11 +643,17 @@ using std::is_integral; # if CXXSTD >= 2014 using std::enable_if_t; using std::conditional_t; +using std::make_signed_t; +using std::make_unsigned_t; # elif CXXSTD >= 2011 template using enable_if_t = typename std::enable_if::type; template using conditional_t = typename std::conditional::type; +template +using make_signed_t = typename std::make_signed::type; +template +using make_unsigned_t = typename std::make_unsigned::type; # endif template @@ -938,6 +944,25 @@ CLAMP_DECL float fclamp2(float in, float min, float max) { return in >= max ? ma #ifdef __cplusplus +#if CXXSTD >= 2011 +template +struct DivResult +{ + T q; // quotient + T r; // remainder +}; +template +FORCE_INLINE CONSTEXPR DivResult divide(T lhs, T rhs) +{ + return DivResult{(T)(lhs / rhs), (T)(lhs % rhs)}; +} +template +FORCE_INLINE CONSTEXPR DivResult divrhs(T lhs) +{ + return divide(lhs, (T)base); +} +#endif + template CONSTEXPR size_t logbase(T n) {