[Endian] Reading/writing from/to byte buffers

Hi, One often needs to read or write values from/to a buffer while having a pointer. Could you support this? I guess one could use *reinterpret_cast<big_int64_buf_t&>(*p) but I think functions would be more convenient. On second guess one probably has to use memcpy rather then reinterpret_cast. The functions are probably implemented already but aren't exposed. https://github.com/boostorg/endian/issues/17 -- Olaf

Aliasing rules in C++ prohibit the use of reinterpret_cast in this situation unless the dynamic type pointed to by p is actually big_int64_buf_t.

On Sat, Jan 28, 2017 at 6:13 AM, David Stone <david@doublewise.net> wrote:
Aliasing rules in C++ prohibit the use of reinterpret_cast in this situation unless the dynamic type pointed to by p is actually big_int64_buf_t.
Right, so something like read_be64(const void*) would be nice to have. Beman? -- Olaf

Ping ;) On Wed, Feb 1, 2017 at 12:04 PM, Olaf van der Spek <ml@vdspek.org> wrote:
On Sat, Jan 28, 2017 at 6:13 AM, David Stone <david@doublewise.net> wrote:
Aliasing rules in C++ prohibit the use of reinterpret_cast in this situation unless the dynamic type pointed to by p is actually big_int64_buf_t.
Right, so something like read_be64(const void*) would be nice to have.
Beman?
-- Olaf
-- Olaf
participants (2)
-
David Stone
-
Olaf van der Spek