Replace calls to AsBytePtr
with calls to AsBytes
or reinterpret_cast
. AsBytePtr
is just a wrapper around reinterpret_cast
. It accepts any type of pointer as an argument and uses reinterpret_cast
to cast the argument to a std::byte
pointer.
Despite taking any type of pointer as an argument, it is not useful to call AsBytePtr
on most types of pointers, because byte representations of most types will be platform specific or undefined. Also, because it is named similarly to the AsBytes
function, AsBytePtr
looks safer than it actually is. Both AsBytes
and AsBytePtr
call reinterpret_cast internally and may be unsafe to use with certain types, but AsBytes at least has some type checking and can only be called on Span
objects, while AsBytePtr
can be called on any pointer argument.
The change was motivated by discussion on #27973 and #27927 and is compatible with those PRs