Subject: Re: [boost] [Endian] Unaligned fields in packed structs
From: Beman Dawes (bdawes_at_[hidden])
Date: 2011-09-10 07:19:55
On Wed, Sep 7, 2011 at 4:44 AM, Mathias Gaunard
> On 09/07/2011 03:08 AM, Beman Dawes wrote:
>> If native_to_big, as an example, was supplied only as:
>> T native_to_big(T x);
>> then the code for big-endian systems wouldn't just be a no-op. A copy,
>> no matter how fast, is a slower than a no-op.
>> Of course a really smart
>> compiler might optimize the do-nothing copy away.
> Assuming T is a POD, if the function is inlined, the copy will be elided.
> I wouldn't think it really requires a particularly smart compiler.
Looking at the generated code, that is definitely the case for the
Microsoft compiler, at least in some initial tests. I'll take a look
at GCC in the next day or so.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk