Bug 1175485 part 2 - Add static_assert to MakeRange to ensure it is used with integers. r=waldo
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 02 Jul 2015 13:31:07 +1000
changeset 284401 addb5b05538307ed1d2c75497ed469e393e6791d
parent 284400 13b68b2357f9505e688fabb4cbfa81da5d63c976
child 284402 685a87f8677c2ba9208f5ef927545d3d9f72f5d5
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1175485
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1175485 part 2 - Add static_assert to MakeRange to ensure it is used with integers. r=waldo
mfbt/IntegerRange.h
--- a/mfbt/IntegerRange.h
+++ b/mfbt/IntegerRange.h
@@ -175,25 +175,28 @@ struct GeqZero<T, true>
 };
 
 } // namespace detail
 
 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);
 }
 
 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");
   return detail::IntegerRange<IntType2>(aBegin, aEnd);
 }
 
 } // namespace mozilla