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)
243
243
return back;
244
244
}
245
245
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
+
246
251
// From C++20 as_bytes and as_writeable_bytes
247
252
template <typename T>
248
253
Span<const std::byte> AsBytes (Span<T> s) noexcept
249
254
{
250
- return {reinterpret_cast < const std::byte*> (s.data ()), s.size_bytes ()};
255
+ return {BytePtr (s.data ()), s.size_bytes ()};
251
256
}
252
257
template <typename T>
253
258
Span<std::byte> AsWritableBytes (Span<T> s) noexcept
254
259
{
255
- return {reinterpret_cast <std::byte*> (s.data ()), s.size_bytes ()};
260
+ return {BytePtr (s.data ()), s.size_bytes ()};
256
261
}
257
262
258
263
template <typename V>
You can’t perform that action at this time.
0 commit comments