summaryrefslogtreecommitdiffstats
path: root/mfbt/Span.h
diff options
context:
space:
mode:
Diffstat (limited to 'mfbt/Span.h')
-rw-r--r--mfbt/Span.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/mfbt/Span.h b/mfbt/Span.h
index d9ba1af220..ca754f3810 100644
--- a/mfbt/Span.h
+++ b/mfbt/Span.h
@@ -41,6 +41,9 @@ namespace mozilla {
template <typename T, size_t Length>
class Array;
+template <typename Enum, typename T, size_t Length>
+class EnumeratedArray;
+
// Stuff from gsl_util
// narrow_cast(): a searchable way to do narrowing casts of values
@@ -488,6 +491,23 @@ class Span {
: storage_(&aArr[0], span_details::extent_type<N>()) {}
/**
+ * Constructor for mozilla::EnumeratedArray.
+ */
+ template <size_t N, class Enum,
+ class ArrayElementType = std::remove_const_t<element_type>>
+ constexpr MOZ_IMPLICIT Span(
+ mozilla::EnumeratedArray<Enum, ArrayElementType, N>& aArr)
+ : storage_(&aArr[Enum(0)], span_details::extent_type<N>()) {}
+
+ /**
+ * Constructor for const mozilla::EnumeratedArray.
+ */
+ template <size_t N, class Enum>
+ constexpr MOZ_IMPLICIT Span(const mozilla::EnumeratedArray<
+ Enum, std::remove_const_t<element_type>, N>& aArr)
+ : storage_(&aArr[Enum(0)], span_details::extent_type<N>()) {}
+
+ /**
* Constructor for mozilla::UniquePtr holding an array and length.
*/
template <class ArrayElementType = std::add_pointer<element_type>,
@@ -852,6 +872,12 @@ Span(mozilla::Array<T, Extent>&) -> Span<T, Extent>;
template <typename T, size_t Extent>
Span(const mozilla::Array<T, Extent>&) -> Span<const T, Extent>;
+template <typename Enum, typename T, size_t Extent>
+Span(mozilla::EnumeratedArray<Enum, T, Extent>&) -> Span<T, Extent>;
+
+template <typename Enum, typename T, size_t Extent>
+Span(const mozilla::EnumeratedArray<Enum, T, Extent>&) -> Span<const T, Extent>;
+
// [Span.comparison], Span comparison operators
template <class ElementType, size_t FirstExtent, size_t SecondExtent>
inline constexpr bool operator==(const Span<ElementType, FirstExtent>& l,