Parcourir la source

AK: Add Span<T> constructor for arrays

The array constructor allows arrays to be easily treated
as generic span of data.
Brian Gianforcaro il y a 4 ans
Parent
commit
21a959e29b
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      AK/Span.h

+ 7 - 0
AK/Span.h

@@ -46,6 +46,13 @@ public:
     {
     }
 
+    template<size_t size>
+    ALWAYS_INLINE constexpr Span(T (&values)[size])
+        : m_values(values)
+        , m_size(size)
+    {
+    }
+
 protected:
     T* m_values { nullptr };
     size_t m_size { 0 };