From 4fa140ec32b8f1bdb82b63a7799a3564d2ad5681 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Tue, 20 Oct 2015 10:16:19 +1100 Subject: [PATCH] Bug 1216038 - Deduce underlying integer type for MakeEnumeratedRange starting at 0. r=froydnj --- mfbt/EnumeratedRange.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mfbt/EnumeratedRange.h b/mfbt/EnumeratedRange.h index 2fd0f881f1f9..109d8dd9d121 100644 --- a/mfbt/EnumeratedRange.h +++ b/mfbt/EnumeratedRange.h @@ -171,6 +171,9 @@ private: #endif // Create a range to iterate from aBegin to aEnd, exclusive. +// +// (Once we can rely on std::underlying_type, we can remove the IntType +// template parameter.) template inline detail::EnumeratedRange MakeEnumeratedRange(EnumType aBegin, EnumType aEnd) @@ -189,11 +192,15 @@ MakeEnumeratedRange(EnumType aBegin, EnumType aEnd) // Create a range to iterate from EnumType(0) to aEnd, exclusive. EnumType(0) // should exist, but note that there is no way for us to ensure that it does! -template -inline detail::EnumeratedRange +// Since the enumeration starts at EnumType(0), we know for sure that the values +// will be in range of our deduced IntType. +template +inline detail::EnumeratedRange::Type, + EnumType> MakeEnumeratedRange(EnumType aEnd) { - return MakeEnumeratedRange(EnumType(0), aEnd); + return MakeEnumeratedRange::Type>( + EnumType(0), aEnd); } #ifdef __GNUC__