Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Terry Golubiewski (tjgolubi_at_[hidden])
Date: 2010-06-03 01:10:29

 const endian<big, T>* src = reinterpret_cast<const
>> endian<big, T>*>(buf);
>> endian<native, T>* dst = reinterpret_cast<endian<native, T>*>(buf);
>> (void) copy(src, src+numTs, dst);
> A call to swap_in_place() avoids the ugly reinterpret_casts and looks far
> simpler.
> Thus far, I'm not convinced that there is any value in the endian types,
> but keep trying!

swap_in_place still needs a reinterpret_cast too to convert from the 'char *
buf' assembled from the hypothetical TCP stream.
What bugs me is that 'buf' doesn't point to a 'T' yet. It points to a
half-baked 'T'. Only after one calls swap_in_place() is the object really a
The reinterpret_casts are valuable here because they show that the
programmer is doing a potentially dangerous thing -- changing the memory
underlying a structure in place!


Boost list run by bdawes at, gregod at, cpdaniel at, john at