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 @@ -243,16 +243,21 @@ T& SpanPopBack(Span<T>& span)
243243 return back;
244244}
245245
246+ // ! Convert a data pointer to a std::byte data pointer.
247+ // ! Where possible, please use the safer AsBytes helpers.
248+ inline const std::byte* BytePtr (const void * data) { return reinterpret_cast <const std::byte*>(data); }
249+ inline std::byte* BytePtr (void * data) { return reinterpret_cast <std::byte*>(data); }
250+
246251// From C++20 as_bytes and as_writeable_bytes
247252template <typename T>
248253Span<const std::byte> AsBytes (Span<T> s) noexcept
249254{
250- return {reinterpret_cast < const std::byte*> (s.data ()), s.size_bytes ()};
255+ return {BytePtr (s.data ()), s.size_bytes ()};
251256}
252257template <typename T>
253258Span<std::byte> AsWritableBytes (Span<T> s) noexcept
254259{
255- return {reinterpret_cast <std::byte*> (s.data ()), s.size_bytes ()};
260+ return {BytePtr (s.data ()), s.size_bytes ()};
256261}
257262
258263template <typename V>
You can’t perform that action at this time.
0 commit comments