|
19 | 19 | // removed some implicit const -> non-const conversions that rely on
|
20 | 20 | // complicated std::enable_if meta-programming
|
21 | 21 | // removed a bunch of slice variants for simplicity...
|
22 |
| -// remove constructors for std::array |
23 | 22 | // remove constructors and operators for std::vector
|
24 | 23 | // removed some prevention of accidental assignments from temporary that
|
25 | 24 | // required std::enable_if meta-programming
|
26 | 25 | // removed reverse iterator
|
27 | 26 |
|
28 | 27 | #pragma once
|
29 | 28 |
|
| 29 | +#include <array> |
30 | 30 | #include <cstdint>
|
31 | 31 |
|
32 | 32 | #include <executorch/runtime/platform/assert.h>
|
@@ -87,6 +87,11 @@ class ArrayRef final {
|
87 | 87 | /// Construct a ArrayRef from a range.
|
88 | 88 | ArrayRef(const T* begin, const T* end) : Data(begin), Length(end - begin) {}
|
89 | 89 |
|
| 90 | + /// Construct an ArrayRef from a std::array |
| 91 | + template <size_t N> |
| 92 | + /* implicit */ constexpr ArrayRef(const std::array<T, N>& Arr) |
| 93 | + : Data(Arr.data()), Length(N) {} |
| 94 | + |
90 | 95 | /// Construct a ArrayRef from a C array.
|
91 | 96 | template <size_t N>
|
92 | 97 | /* implicit */ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
|
@@ -202,6 +207,12 @@ ArrayRef<T> makeArrayRef(const T* begin, const T* end) {
|
202 | 207 | return ArrayRef<T>(begin, end);
|
203 | 208 | }
|
204 | 209 |
|
| 210 | +/// Construct an ArrayRef from a std::array. |
| 211 | +template <typename T, std::size_t N> |
| 212 | +ArrayRef<T> makeArrayRef(const std::array<T, N>& Arr) { |
| 213 | + return Arr; |
| 214 | +} |
| 215 | + |
205 | 216 | /// Construct an ArrayRef from an ArrayRef (no-op) (const)
|
206 | 217 | template <typename T>
|
207 | 218 | ArrayRef<T> makeArrayRef(const ArrayRef<T>& Vec) {
|
|
0 commit comments