Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Endian mini-review
From: Beman Dawes (bdawes_at_[hidden])
Date: 2015-01-24 13:00:44


On Sat, Jan 24, 2015 at 10:52 AM, Olaf van der Spek <ml_at_[hidden]> wrote:
> On Sat, Jan 24, 2015 at 3:54 PM, Beman Dawes <bdawes_at_[hidden]> wrote:
>> struct
>> {
>> big_int32_buf_t code;
>> big_uint32_buf_t length;
>> little_int16_buf_t version;
>> big_int32_buf_ut shape_type;
>> } data;
>
> You're mixing aligned and unaligned types. Shouldn't all be unaligned?

In theory, yes. If data_t ever got embedded into a larger structure at
an unaligned location, that would matter. Unaligned types would also
protect against architectures that required super-alignment or don't
support 16/32/64 bit integer types, but I'm not sure such
architectures actually exist anymore.

In practice, the enhanced efficiency of aligned types is usually more
important than worry about someday encountering an odd-ball
architecture or use in an unaligned location. But it is an engineering
tradeoff, so you can make the choice whichever way seems appropriate
to your application.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk