summaryrefslogtreecommitdiffstats
path: root/mfbt/Span.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /mfbt/Span.h
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 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,