$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Beman Dawes (bdawes_at_[hidden])
Date: 2006-05-31 12:07:47
"me22" <me22.ca_at_[hidden]> wrote in message 
news:fa28b9250605310817l2d71b783j9e92bd247619d313_at_mail.gmail.com...
> On 5/31/06, Beman Dawes <bdawes_at_[hidden]> wrote:
>> Back in 1999 and 2000, there was discussion of a Boost Endian library to
>> provided portable big and little endian integer types. I've dusted off
>> some old code from Darin Adler, gotten his permission to use the new
>> Boost license, and have put together a library.
>>
>> Comments welcome!
>>
>
> Very interesting library.  I've written something before with similar
> functionality, but using a rather different approach.
>
> I haven't tried it yet, jut here are a few comments from looking at
> the code and documentation:
>
> The link to http://mysite.verizon.net/example/example1.cpp is broken
I only put the main html file up - if you unpack the .zip file, the link 
will hopefully work OK.
> Why not expose the template implementation and remove the typedefs?
> Presumably Boost.Integer-style template manipulations could be used to
> find the appropriate storage types.
The rationale for typedefs is that when an application uses endian classes, 
they are often used very heavily. Think hundreds, thousands, or even more 
uses in an organization. So, the names should be short, and all developers 
should use the same names.
The rationale for hiding the templates was that some implementations may 
prefer to provide hand-coded implementations of each type, either to speed 
compiles or to achieve platform specific optimizations. (I don't recommend 
the latter because of a lot of past experience where optimizations became 
pessimizations when something as simple as a compiler switch changed.)
That said, I guess there could be an argument to expose the templates for 
those who prefer them.
> I think the names for the types might be a little bit too cute.  "bin"
> makes me think binary, not signed big-endian.  That being said, I'm
> not sure I have any good name that isn't far too verbose.
> unsigned_littleendian_aligned<4> is admittedly starting to push
> convenience, though bigendian<5> isn't too bad.
I'm often amazed at the clever names Boosters suggest, so I think it is 
worthwhile to speculate a bit about better names. But the everyday use 
typedefs really do need to be short and memorable. I've been using the 
"bin2", "bun3", etc. since 1984 or so, with several hundred programmers now 
using them all the time, and never had a request to change the names.
> Some sort of size method would be nice so that
> out.write( reinterpret_cast<char*>(&big5), 5 );
> could instead be
> out.write( reinterpret_cast<char*>(&big5), big5.size() );
> to avoid the magic constant.
I guess I shouldn't have used that example, since it isn't realistic. In the 
real world, the endian classes are almost always used in classes or structs, 
and the I/O is usually Unix or fstream level rather than iostreams.
A more typical use might be something like:
  struct header_record
  {
     bun3 version;
     bun1 rev;
     bun5 nrecs;
     ..... blah blah blah
  };
Thanks for the comments,
--Beman