Skip to content
Snippets Groups Projects
Commit 0a629d82 authored by Xidorn Quan's avatar Xidorn Quan
Browse files

Bug 1175485 part 2 - Add static_assert to MakeRange to ensure it is used with integers. r=waldo

--HG--
extra : source : ca970199a7f1ee9adc11019a65ef8eba1f2a491e
parent f15e97fc
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,7 @@ template<typename IntType>
detail::IntegerRange<IntType>
MakeRange(IntType aEnd)
{
static_assert(IsIntegral<IntType>::value, "value must be integral");
MOZ_ASSERT(detail::GeqZero<IntType>::check(aEnd),
"Should never have negative value here");
return detail::IntegerRange<IntType>(aEnd);
......@@ -189,6 +190,8 @@ template<typename IntType1, typename IntType2>
detail::IntegerRange<IntType2>
MakeRange(IntType1 aBegin, IntType2 aEnd)
{
static_assert(IsIntegral<IntType1>::value && IsIntegral<IntType2>::value,
"values must both be integral");
static_assert(IsSigned<IntType1>::value == IsSigned<IntType2>::value,
"signed/unsigned mismatch");
MOZ_ASSERT(aEnd >= aBegin, "End value should be larger than begin value");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment