mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-18 23:21:43 +00:00
compat.h: Add some more math stuff to support the next commit.
git-svn-id: https://svn.eduke32.com/eduke32@6138 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
83c06a63b9
commit
5a0ed69310
1 changed files with 25 additions and 0 deletions
|
@ -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 <bool B, class T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
template<bool B, class T, class F>
|
||||
using conditional_t = typename std::conditional<B, T, F>::type;
|
||||
template <typename T>
|
||||
using make_signed_t = typename std::make_signed<T>::type;
|
||||
template <typename T>
|
||||
using make_unsigned_t = typename std::make_unsigned<T>::type;
|
||||
# endif
|
||||
|
||||
template <size_t size>
|
||||
|
@ -938,6 +944,25 @@ CLAMP_DECL float fclamp2(float in, float min, float max) { return in >= max ? ma
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#if CXXSTD >= 2011
|
||||
template <typename T>
|
||||
struct DivResult
|
||||
{
|
||||
T q; // quotient
|
||||
T r; // remainder
|
||||
};
|
||||
template <typename T>
|
||||
FORCE_INLINE CONSTEXPR DivResult<T> divide(T lhs, T rhs)
|
||||
{
|
||||
return DivResult<T>{(T)(lhs / rhs), (T)(lhs % rhs)};
|
||||
}
|
||||
template <native_t base, typename T>
|
||||
FORCE_INLINE CONSTEXPR DivResult<T> divrhs(T lhs)
|
||||
{
|
||||
return divide(lhs, (T)base);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <size_t base, typename T>
|
||||
CONSTEXPR size_t logbase(T n)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue