
----- Original Message ----- From: "Scott McMurray" <me22.ca+boost@gmail.com> To: <boost@lists.boost.org> 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@wanadoo.fr> 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: http://lists.boost.org/Archives/boost/2008/05/137820.php
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? Vicente