Boost logo

Boost :

From: Kevin Lynch (krlynch_at_[hidden])
Date: 2001-10-10 10:56:02

Eric Ford wrote:
> > I've uploaded my current version of a templatized interface to the
> > Standard Math Functions to the vault: standard_functions/std_math.
> Using g++ 2.95, after doing both the defines, I needed to replace the
> include file sstream with strstrstream and
> the two lines of
> ostringstream os;
> with
> ostrstream os;

Sigh... I'll have to do something about that, I guess. I remember there
being a long discussion about this issue on the list sometime back; I'll
have to go see what the solution was.

> Also, I'd recommend eithing #undef'ing STD and STDNAME in
> cmath_test.cpp before redefining them, or using an #else to only
> define them once.

I've fixed this, and will upload it later

> Also, is there a reason why you used a few static_casts rather than
> numeric_cast in cmath.hpp? If it's for optimization's sake, then I
> think it's reasonable to make them all numeric_cast's and assume that
> in the not too distant future numeric_cast will be optimized to become
> just a static_cast when appropriate.

Actually, I just did it to make sure everything would compile nice and
happy before messing with numeric_cast<>, since I haven't read the
documentation, and couldn't figure out what it was doing (For example,
shouldn't I be able to do numeric_cast<double>(int), at least in
principle? If I can't, we'll still need at least some of the
static_casts that are currently in the code). I'll try to read the
documentation, and fix the casting wherever it appears.

And we should see about fixing the optimization issues with numeric_cast
soon, if at all possible; it could be a real performance killer in those
cases where it prevents optimizers from removing all the code we've
written :-) Looking at the generated assembly code, when the calls
aren't optimized away the object code size doubles (at least under gcc).

> Otherwise compiles and looks good to me.
> E

Other things I've fixed since my upload yesterday (which fixes I will
upload when I am done writing this list):

-> Added the type promotion code to pow and div ... it seems to work OK.
-> Added preliminary support for C99 functions ... WFM on gcc (yes, I
realize that three of the tests fail, but that is because nan != nan ...
I'll fix this issue later as well)
-> Fixed the macro issue above
-> Updated the docs to reflect these things

What I haven't done:

-> Fixing the casts as discussed above; I'll have to read the
documentation and get back to this one.
-> Fixing the ostrstream issue above, which may be as simple as
eliminating use entirely; I only use a strstream to beautify the output
of div_t and ldiv_t in the test program, and that beautification can be
done away with entirely.
-> Some other major/minor issues that are mentioned in the

The modified code is on its way to the vault .... concentrate on
std_math.hpp and the associated support files for now if you don't have
time to deal with the C99 layer.

Kevin Lynch				voice:	 (617) 353-6065
Physics Department			Fax: (617) 353-6062
Boston University			office:	 PRB-565
590 Commonwealth Ave.			e-mail:	 krlynch_at_[hidden]
Boston, MA 02215 USA

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