From: "Paul Ranson"
This is a multi-part message in MIME format.
------=_NextPart_000_002F_01C4C712.A2BADAF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
"Geo" wrote in message
news:41918a94$3{at}w3.nls.net...
> That's the other difference I saw with a type vs a class, a type =
defines
> certain operators and not others, it limits things. For example with
> unsigned int you are limited in that you can't use abs.
'abs' is a function in the library rather than an operator. It would be =
completely pointless to call it for an unsigned value....
But should you want to, here it is,
#include
template T geos_abs ( T t ) {
if ( std::numeric_limits::is_signed )
return abs ( t ) ;
return t ;
}
The compiler should be clever enough to optimise it away completely in = all cases.
Paul
------=_NextPart_000_002F_01C4C712.A2BADAF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
"Geo" <mailto:georger{at}nls.net">
size=3D2>georger{at}nls.net> wrote in message =
news:41918a94$3{at}w3.nls.net...
> That's the other difference I saw
with a type =
vs a class,=20
a type defines> certain operators and not others, it
limits = things. For=20
example with> unsigned int you are limited in that you
can't use=20 abs.
'abs' is a function in the library rather than an =
operator. It=20
would be completely pointless to call it for an unsigned =
value....
But should you want to, here it
is,
#include=20
<limits>
template < =
typename T >=20
T geos_abs ( T t )
{
if =
(=20
std::numeric_limits<T>::is_signed )
return abs (
t ) ;
=
return t=20
;
}
The compiler should be clever enough to optimise it =
away=20
completely in all cases.
Paul
------=_NextPart_000_002F_01C4C712.A2BADAF0--
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)
SEEN-BY: 633/267 270 5030/786
@PATH: 379/45 1 396/45 106/2000 633/267
|