
27 May
2010
27 May
'10
7:01 p.m.
At that point, however, the functional approach seems more straightforward.
We sometimes deal with messages with mixed endianness. A functional approach means the programmer has to "know" which endianess the data he wants to swap is. With the endian<endian_t, T> approach, the message can contain fields with varying endianess and the structure is self-documenting. struct MyStruct { ... }; struct Msg { endian<little, uint32_t> x; endian<big, uint16_t> y; endian<big, MyStruct> z; endian<little, double> w; }; I attached a working (?) program that demonstrates this and a assembly listing showing the optimized results. terry