
I wrote the attached code years ago. When I noticed the proposed Boost Endian library, I figured now was as good a time as any to share it. My code provides an alternative solution to Beman's boost::integer::endian_flip function that may or may not be a useful improvement. My implementation exposes a single function template, boost::endian::swap, that accepts any type, but only swaps the endianness of 16-bit, 32-bit, and 64-bit types.
Hi Mike, Not to discourage you but I tried something similar a few months ago - I argued that the proposed endian library should be built on top of simpler swap() and swap_in_place() primitives. I also put together a quick implementation of the proposed interfaces (which, had a few issues) but in the end it seemed that most people here simply wanted to use endian types. I am sure you can find the posts pretty easily, they were from last July-ish. Good luck, Tom