diff options
author | Moonchild <moonchild@palemoon.org> | 2023-10-18 14:35:59 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-11-05 13:16:39 +0100 |
commit | c87116b33267a8df388ca3652d211b7f8254a98d (patch) | |
tree | 8823d7815df612885a5769d6ede196b261041779 | |
parent | e29ae4e08ccce7f120f8ee88dd238bd2b4facbf4 (diff) | |
download | uxp-c87116b33267a8df388ca3652d211b7f8254a98d.tar.gz |
Issue #2281 - Add some deduction guides for class template arguments.
This is necessary if we want to start using Span() constructors
instead of the MakeSpan() kludge.
-rw-r--r-- | mfbt/Span.h | 9 | ||||
-rw-r--r-- | xpcom/glue/nsTArray.h | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/mfbt/Span.h b/mfbt/Span.h index e71e068c60..fe679aa8bf 100644 --- a/mfbt/Span.h +++ b/mfbt/Span.h @@ -810,6 +810,15 @@ private: storage_type<span_details::extent_type<Extent>> storage_; }; +template <typename T, size_t Extent> +Span(T (&aArr)[Extent]) -> Span<T, Extent>; + +template <class Container> +Span(Container&) -> Span<typename Container::value_type>; + +template <class Container> +Span(const Container&) -> Span<const typename Container::value_type>; + // [Span.comparison], Span comparison operators template<class ElementType, size_t FirstExtent, size_t SecondExtent> inline bool diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index 03913a3765..47635de318 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -2466,6 +2466,12 @@ MakeSpan(const nsTArray_Impl<ElementType, TArrayAlloc>& aTArray) return aTArray; } +template <typename E, class Alloc> +Span(nsTArray_Impl<E, Alloc>&) -> Span<E>; + +template <typename E, class Alloc> +Span(const nsTArray_Impl<E, Alloc>&) -> Span<const E>; + } // namespace mozilla // Assert that AutoTArray doesn't have any extra padding inside. |