Boost logo

Boost :

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


----- Original Message -----
From: "Frank Mori Hess" <frank.hess_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, September 26, 2008 3:18 PM
Subject: Re: [boost] hton/ntoh template functions

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 25 September 2008 16:50 pm, vicente.botet wrote:
> vicente.botet a écrit :
> > > Hi,
> > >
> > > 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).
> > >
> > > <snip>
> >
> > Why are they template ? Atfer all, the 3 overload is fully sufficent I
> > think
>
> Oups! You are right.

A template would make it harder to accidentally do an implicit conversion of
an unsupported argument type before it is byte swapped.

Hi,

you are right, and I think that we don't need accidental implicit
conversions. I have tested with and withou the template and there is a
conclict without.

Vicente_at_viboes1 ~
$ g++ test_endian_conversions.cpp -o test
/cygdrive/c/DOCUME~1/Vicente/LOCALS~1/Temp/cc2WdPFL.o:test_endian_conversions.cp
p:(.text+0x21f): undefined reference to `S host_to_network<S>(S)'
/cygdrive/c/DOCUME~1/Vicente/LOCALS~1/Temp/cc2WdPFL.o:test_endian_conversions.cp
p:(.text+0x22d): undefined reference to `S network_to_host<S>(S)'
collect2: ld returned 1 exit status

Thanks for pointing the difference.

Vicente


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