Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Terry Golubiewski (tjgolubi_at_[hidden])
Date: 2010-05-27 15:01:49


> 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






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