|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-28 14:10:04
----- Original Message -----
From: Kevin Lynch <krlynch_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, September 28, 2001 3:52 PM
Subject: [boost] Re: Math Functions: Basic building blocks...
> Eric Ford Wrote:
>
> >> Kevin Lynch wrote:
> >> C99 (not C89, and hence not ISO-C++) defines the "suffix functions"
> >> (such as sinf for float arguments, sinl for long double, etc).
> These
> >> are therefore NOT part of the ISO-C++ standard, and I don't think
> you
> >> should be using them as the "implementation" for the template
> functions
> >> for a standards compliant, portable "reference implementation". But
> you
> >> don't need them anyway, I don't think, since the standard overload
> >> resolution mechanism should allow the compiler to pick the right
> >> overloaded function.
>
> > You may be right about what the standards specify. However with g++
> > 2.95, it looks like there is no overloading for float sin(float x) or
> > long double sin(long double x).
>
> Yup, I discovered exactly the same thing last night when I was hacking
> on the code .... what I said about the standards is correct, but the
> real world is being problematic :-)
>
> In the "3.0" version of the gcc ANSI C++ library (an "in progress"
> version ships with the gcc-2.96 suite that ships with Redhat 7.1), if
> you take a look in <cmath>, you'll find all the overload prototypes, but
> they are commented out with a #if 0 as there don't appear to (yet)
> be implementations of these functions. This same library, however, DOES
> have implementations of the "suffix functions" from C99. (It gets
> wierder on the x86 ... the implementations of all three functions, sinf,
> sin, sinl for example, are identical assembly code in glibc ... not a
> bit of difference that I could detect, meaning, I think, that the
> assembly generated from these templates will be doing casting on the too
> and from the fpu, even with the choice of the correct template :-(
>
Borland C++ 5.5.1 contains only double and long double (with the 'l' suffix)
versions.
There is no float overload.
I've looked at the source files and (at least for the functions cos/cosl and
abs/absl that I checked) the implementation is truly double/long double.
I'm not sure if macro flags would work in all cases. How about a separate
'cmath_compatibility.hpp' header, compiler specific, that defines all the
missing overloads? That way, standard_functions.hpp can just pretend all the
overloads are present.
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk