Alternatively these could be special cased in endian::Writer
Details
Diff Detail
Event Timeline
Why are you using a memcpy for the implementation?
You may have a good reason, but since it is not obvious to me it may deserve a comment so it won't get remove in the future.
It does not seems true in C, I'm unsure for C++.
See the first answer here for instance: http://stackoverflow.com/questions/11442708/type-punning-and-unions-in-c
Because we are writing C++ and not C I tried to find what C++11 says about type punning:
"An lvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointer to T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast. That is, a reference cast reinterpret_cast<T&>(x) has the same effect as the conversion *reinterpret_cast<T*>(&x) with the built-in & and * operators (and similarly for reinterpret_cast<T&&>(x)). The result refers to the same object as the source lvalue, but with a different type. The result is an lvalue for an lvalue reference type or an rvalue reference to function type and an xvalue for an rvalue reference to object type. No temporary is created, no copy is made, and constructors (12.1) or conversion functions (12.3) are not called."
So I assume this should be valid:
return SwapByteOrder_64(reinterpret_cast<int &>(C));