Boost logo

Boost :

Subject: Re: [boost] [Endian] Review
From: Tomas Puverle (Tomas.Puverle_at_[hidden])
Date: 2011-09-12 10:47:40


> A class template, perhaps named "endian_buffer", that is the same as
> the current class endian except it does not provide the operators. The
> typedefs provided would have "buf" added to the name (E.G. big32buf_t,
> etc.)

Beman,

I would be in full support of this approach. In fact, it's along the lines of
what I was thinking when I suggested this signature for the "swap" function:

template<typename T_>
swapped_data<T_> native_to_big(T_)

Clearly, your endian_buffer<> is very closely related to the above. However, in
my original email I didn't pursue the concept because I felt I already made too
many suggestions.

But since we're throwing out ideas, here are a few, off the cuff. I am not
married to this interface, but I think it points out the different things you
may want to do with an endian_buffer:

template<typename T_, bool Aligned_, std::size_t Size_ = sizeof(T_)>
class endian_buffer;

endian_buffer<void, ...> e1;
uint32_t x1 = big_to_native<uint32_t>(e1);

endian_buffer<uint32_t, ...> e2;
uint32_t x2 = big_to_native(e2);

endian_buffer<uint32_t, true> e3;
uint32_t & x3 = reorder_big_to_native(e3);

Cheers,

Tom


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