Boost logo

Boost :

Subject: Re: [boost] hton/ntoh template functions
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-09-27 03:56:01

----- Original Message -----
From: "Scott McMurray" <[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, September 25, 2008 9:30 PM
Subject: Re: [boost] hton/ntoh template functions

> On Thu, Sep 25, 2008 at 15:03, vicente.botet <vicente.botet_at_[hidden]>
> wrote:
>> currently most of the applications that must take care of endianess use
>> ntohl/htonl ntohs/htons functions.
>> When the size of the integer change we need to change between the -s
>> and -l
>> functions (or maybe remove the call for chars).
> Have you looked at the proposed Boost.Endian library? It's a very
> elegant way of handling things:

Yes, I do.

> That said, it's a different philosophy from in-place byte swapping, so
> it might not fit what you need.

There is one factor, it could be very simple to transform a program using
the htons htonl version to the polymorphic ones. Evidently this has no
importance for new code.

The transparency will make easier bad uses of these endian types in parts
not related to I/O. IMO it will be better if the endian library provides in
addition to the already provided types the corresponding opaque byte holder
types that do not provide the integer arithmetics operators. This will force
the separation between the application and the physical presentation.

What do you think Beman?


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