File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ class Span : public Detail::Span<T> {
125125public:
126126 using Detail::Span<T>::Span;
127127
128+ using ElementType = T;
129+
128130 constexpr Span () = default;
129131
130132 [[nodiscard]] ALWAYS_INLINE constexpr T const * data () const { return this ->m_values ; }
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ template<>
139139ErrorOr<void > encode (Encoder&, URL::BlobURLEntry::MediaSource const &);
140140
141141template <Concepts::Span T>
142+ requires (!IsArithmetic<typename T::ElementType>)
142143ErrorOr<void > encode (Encoder& encoder, T const & span)
143144{
144145 TRY (encoder.encode_size (span.size ()));
@@ -149,6 +150,18 @@ ErrorOr<void> encode(Encoder& encoder, T const& span)
149150 return {};
150151}
151152
153+ template <Concepts::Span T>
154+ requires (IsArithmetic<typename T::ElementType>)
155+ ErrorOr<void > encode (Encoder& encoder, T const & span)
156+ {
157+ TRY (encoder.encode_size (span.size ()));
158+
159+ VERIFY (!Checked<size_t >::multiplication_would_overflow (span.size (), sizeof (typename T::ElementType)));
160+ TRY (encoder.append (reinterpret_cast <u8 const *>(span.data ()), span.size () * sizeof (typename T::ElementType)));
161+
162+ return {};
163+ }
164+
152165template <typename T, size_t N>
153166ErrorOr<void > encode (Encoder& encoder, Array<T, N> const & array)
154167{
You can’t perform that action at this time.
0 commit comments