File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -237,16 +237,21 @@ T& SpanPopBack(Span<T>& span)
237237 return back;
238238}
239239
240+ // ! Convert a data pointer to a std::byte data pointer.
241+ // ! Where possible, please use the safer AsBytes helpers.
242+ inline const std::byte* BytePtr (const void * data) { return reinterpret_cast <const std::byte*>(data); }
243+ inline std::byte* BytePtr (void * data) { return reinterpret_cast <std::byte*>(data); }
244+
240245// From C++20 as_bytes and as_writeable_bytes
241246template <typename T>
242247Span<const std::byte> AsBytes (Span<T> s) noexcept
243248{
244- return {reinterpret_cast < const std::byte*> (s.data ()), s.size_bytes ()};
249+ return {BytePtr (s.data ()), s.size_bytes ()};
245250}
246251template <typename T>
247252Span<std::byte> AsWritableBytes (Span<T> s) noexcept
248253{
249- return {reinterpret_cast <std::byte*> (s.data ()), s.size_bytes ()};
254+ return {BytePtr (s.data ()), s.size_bytes ()};
250255}
251256
252257template <typename V>
You can’t perform that action at this time.
0 commit comments