summaryrefslogtreecommitdiffstats
path: root/mfbt/Span.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /mfbt/Span.h
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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,