Issue #2166 - Part 3: Make tl::Min/Max variadic

Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1338374
This commit is contained in:
FranklinDM committed 2023-03-17 20:29:19 +08:00
1 parent 5e6a0efb65
commit 88d2d5eef6
1 file changed
+23 -4
+23 -4
View File
@@ -26,15 +26,34 @@ namespace mozilla {
namespace tl {
/** Compute min/max. */
template<size_t I, size_t J>
template<size_t Size, size_t... Rest>
struct Min
{
static const size_t value = I < J ? I : J;
static const size_t value =
Size < Min<Rest...>::value
? Size
: Min<Rest...>::value;
};
template<size_t I, size_t J>
template<size_t Size>
struct Min<Size>
{
static const size_t value = Size;
};
template<size_t Size, size_t... Rest>
struct Max
{
static const size_t value = I > J ? I : J;
static const size_t value =
Size > Max<Rest...>::value
? Size
: Max<Rest...>::value;
};
template<size_t Size>
struct Max<Size>
{
static const size_t value = Size;
};
/** Compute floor(log2(i)). */