diff options
-rw-r--r-- | mfbt/TemplateLib.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/mfbt/TemplateLib.h b/mfbt/TemplateLib.h index 415bba4581..8ab875d21a 100644 --- a/mfbt/TemplateLib.h +++ b/mfbt/TemplateLib.h @@ -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)). */ |