mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 1891497 - Add mozilla::Span constructor for EnumeratedArray. r=glandium
Just like the mozilla::Array/std::array ones. Differential Revision: https://phabricator.services.mozilla.com/D207389
This commit is contained in:
parent
0e73760a15
commit
6d4e823315
26
mfbt/Span.h
26
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
|
||||
@ -487,6 +490,23 @@ class Span {
|
||||
const mozilla::Array<std::remove_const_t<element_type>, N>& aArr)
|
||||
: 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.
|
||||
*/
|
||||
@ -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,
|
||||
|
@ -1760,7 +1760,7 @@ static void MakeRegionsNonOverlapping(Span<LayoutDeviceIntRegion> aRegions) {
|
||||
void nsChildView::UpdateVibrancy(
|
||||
const nsTArray<ThemeGeometry>& aThemeGeometries) {
|
||||
auto regions = GatherVibrantRegions(aThemeGeometries);
|
||||
MakeRegionsNonOverlapping(Span(regions.begin(), regions.end()));
|
||||
MakeRegionsNonOverlapping(regions);
|
||||
|
||||
auto& vm = EnsureVibrancyManager();
|
||||
bool changed = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user