Boost logo

Boost :

Subject: Re: [boost] [Endian] Unaligned fields in packed structs
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-09-07 04:44:15


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.


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