[Endian] Reading/writing from/to byte buffers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Endian] Reading/writing from/to byte buffers

Olaf van der Spek-3
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Endian] Reading/writing from/to byte buffers

David Stone
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.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Endian] Reading/writing from/to byte buffers

Olaf van der Spek-3
On Sat, Jan 28, 2017 at 6:13 AM, David Stone <[hidden email]> 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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Endian] Reading/writing from/to byte buffers

Boost - Dev mailing list
Ping ;)

On Wed, Feb 1, 2017 at 12:04 PM, Olaf van der Spek <[hidden email]> wrote:

> On Sat, Jan 28, 2017 at 6:13 AM, David Stone <[hidden email]> 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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...