|
Boost : |
From: Ed Brey (brey_at_[hidden])
Date: 2001-04-19 14:39:16
--- In boost_at_y..., "Paul A. Bristow" <pbristow_at_h...> wrote:
>
> BUT I am VERY keen to use the macro values because of the
> long and tedious work in altering the generation program
> to write this file with the constants embedded as above.
> (And to write a validation program too!)
> (And it leaves the file of macros useful for C programs -
> I agree that should be at no extra cost to C++ users).
I appreciate that it may be bad to have to change the generator
program. In that caes, rather than dealing with all the macro
problems, the easiest solution is to take the C header and have a
program generate a nice C++ header from it. This gives the cleanest
possible end result with minimal effort. I've uploaded a program to
do the conversion to:
http://groups.yahoo.com/group/boost/files/MathConstants/makehpp.py
> #include math_constants.h -- the values like BOOST_PI
> > namespace boost {
> > namespace math {
> > template<typename T>
> > struct constants {
> > static T pi() {return T(BOOST_PI);} << use the macro names
here.
> ... all the others.
> // (Does adding all constants here cost too much in link file
size?)
> > };
> > }
> > }
I did a test on VC6SP5 and found that there was zero overhead for
functions that are not called, presumably since everything is inline.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk