40 lines
968 B
C++
40 lines
968 B
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: auNumberUtils.hpp
|
|
Date: 2022-2-1
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
template <typename A, typename B, typename Ret_t =
|
|
AuConditional_t<AuIsClass_v<A>, A, AuCommonType_t<A, B>>>
|
|
constexpr Ret_t AuMin(const A &a, const B &b)
|
|
{
|
|
return a < b ? a : b;
|
|
}
|
|
|
|
template <typename A, typename B, typename Ret_t =
|
|
AuConditional_t<AuIsClass_v<A>, A, AuCommonType_t<A, B>>>
|
|
constexpr Ret_t AuMax(const A &a, const B &b)
|
|
{
|
|
return a < b ? b : a;
|
|
}
|
|
|
|
template <class T>
|
|
constexpr const T AuConstPow(const T base, const AuUInt8 exponent)
|
|
{
|
|
return exponent ? base * AuConstPow(base, exponent - 1) : 1;
|
|
}
|
|
|
|
template <class T>
|
|
constexpr const T AuPageRoundUp(const T value, const T pageSize)
|
|
{
|
|
return (value + (pageSize - 1)) & ~(pageSize - 1);
|
|
}
|
|
|
|
template <class T>
|
|
constexpr const T AuPageRound(const T value, const T pageSize)
|
|
{
|
|
return value & ~(pageSize - 1);
|
|
} |