Boost logo

Boost :

From: me22 (me22.ca_at_[hidden])
Date: 2006-05-31 11:17:18


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

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.

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.

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 agree that operator<< cannot be used for binary output, but
reinterpret_cast-and-write "smells" to me. What about using operator<
or operator<=? They have similar precedence to << and >>, and are
visually similar enough that the connection might be decently
intuitive. Something involving & could also be nice, mirroring
Serialisation, but I don't know of a good way of using anything with &
in a nice way with a bidirectional stream without going the full
Serialization framework route.

~ Scott McMurray


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