Bug 1216040 - Make ArrayLength support mozilla::EnumeratedArray. r=froydnj
authorCameron McCormack <cam@mcc.id.au>
Tue, 20 Oct 2015 10:16:20 +1100
changeset 268438 c24e66d011eca8cf40bd5e48bacc804e429652c3
parent 268437 1f8cd027929b4808ea2f7c121261d47a81839cff
child 268439 c3e202bf0f25772c0eb34078db586449e51ccd00
push id29551
push usercbook@mozilla.com
push dateTue, 20 Oct 2015 10:01:15 +0000
treeherdermozilla-central@f7b746b4e913 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1216040
milestone44.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 1216040 - Make ArrayLength support mozilla::EnumeratedArray. r=froydnj
mfbt/ArrayUtils.h
--- a/mfbt/ArrayUtils.h
+++ b/mfbt/ArrayUtils.h
@@ -15,16 +15,17 @@
 #include "mozilla/Attributes.h"
 
 #include <stddef.h>
 
 #ifdef __cplusplus
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Array.h"
+#include "mozilla/EnumeratedArray.h"
 #include "mozilla/TypeTraits.h"
 
 namespace mozilla {
 
 /*
  * Safely subtract two pointers when it is known that aEnd >= aBegin, yielding a
  * size_t result.
  *
@@ -59,16 +60,23 @@ ArrayLength(T (&aArr)[N])
 
 template<typename T, size_t N>
 MOZ_CONSTEXPR size_t
 ArrayLength(const Array<T, N>& aArr)
 {
   return N;
 }
 
+template<typename E, E N, typename T>
+MOZ_CONSTEXPR size_t
+ArrayLength(const EnumeratedArray<E, N, T>& aArr)
+{
+  return size_t(N);
+}
+
 /*
  * Compute the address one past the last element of a constant-length array.
  *
  * Beware of the implicit trailing '\0' when using this with string constants.
  */
 template<typename T, size_t N>
 MOZ_CONSTEXPR T*
 ArrayEnd(T (&aArr)[N])