Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Summary of discussion #1
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2010-06-03 12:44:33


On 3 June 2010 12:30, Terry Golubiewski <tjgolubi_at_[hidden]> wrote:
> Tom wrote:
>>
>> endian::cast<big_to_host>()  //explicit direction
>> endian::cast<from_litle>()   //"to_host" is implicit
>> endian::cast<to_big>()       //"from_host" is implicit
>>
>
> Is it imporant that these names are templated?  What are the advantages of
> this templated-tagged design over..
>

I also find it odd that the direction is mixed in with the endianness.
 I'd expect something like to_host_endian and from_host_endian, with a
policy type for the endianness. (Perhaps the big and little types
could be formalized policies, in a way that there could be a
custom<1,3,0,4> endian type for very strange endians, with big and
little just being instances thereof, perhaps with specializations for
speed if needed.)

The only advantage I see of the explicit one is that it theoretically
allows cast<big_to_little>, but that would mean defining a number of
types quadratic in the number of endiannesses. It clearly has no
speed benefit over to_host then from_host on typical machines. I'm
also not certain that it's even a useful operation.


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