
10 Sep
2011
10 Sep
'11
11:19 a.m.
On Wed, Sep 7, 2011 at 4:44 AM, Mathias Gaunard <mathias.gaunard@ens-lyon.org> wrote:
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. Thanks, --Beman