From 88d2d5eef62a726cf4b4081e9f48f3ef6e2bbff2 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 17 Mar 2023 18:54:21 +0800 Subject: Issue #2166 - Part 3: Make tl::Min/Max variadic Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1338374 --- mfbt/TemplateLib.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'mfbt') 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 +template struct Min { - static const size_t value = I < J ? I : J; + static const size_t value = + Size < Min::value + ? Size + : Min::value; }; -template + +template +struct Min +{ + static const size_t value = Size; +}; + +template struct Max { - static const size_t value = I > J ? I : J; + static const size_t value = + Size > Max::value + ? Size + : Max::value; +}; + +template +struct Max +{ + static const size_t value = Size; }; /** Compute floor(log2(i)). */ -- cgit v1.2.3