Open OlafvdSpek opened 5 years ago
What's wrong with memcpy?
Doesn't support big-endian (or little-endian) and has the wrong API.
The requested function should return the int.
This has been on our TODO list for a while. Some of it can be found in https://github.com/abseil/abseil-cpp/blob/master/absl/base/internal/endian.h in an internal namespace. We'd like to do an API review and then officially release this.
I think absl/base/internal/endian.h
is missing a lot of stuff, is the proposed API viewable somewhere already?
absl/base/internal/endian.h
only contains stuff needed by Abseil currently. Whatever we release will likely be more complete.
We are tracking progress of this in b/62646255, but there is no concrete plans to release these interfaces yet.
In low-level code one sometimes has to read or write integers that may be unaligned, may be big endian, little endian or native. Could functions for this be provided? The non-native ones are non-trivial.
IMO the language itself should provide these as intrinsics but until then..
A reinterpret_cast isn't sufficient: https://github.com/abseil/abseil-cpp/issues/269