Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2001-04-19 13:53:08


> -----Original Message-----
> From: Ed Brey [mailto:brey_at_[hidden]]
> Sent: Thursday, April 19, 2001 4:19 PM
> To: boost_at_[hidden]
> Subject: [boost] Boost.MathConstants: Review
>
I am content to provide an .hpp file of this form

> namespace boost {
> namespace math {
> template<typename T>
> struct constants {
> static T pi() {return T(3.1415...L);}
> };
> }
> }
>
> where a typical user experience would be documented as this:
>
> typedef boost::math::constants<float> c;
> std::cout << "Baseball and apple " << c::pi();

as suggested (but alas not suggested in previous discussions!)

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).

So in outline
  math_constants.hpp
would be

#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?)
> };
> }
> }

#include undefine.h

which does #undef BOOST_PI

- to avoid any memory of macro names.

Is this acceptable?

Paul

Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
mailto:pbristow_at_[hidden]
 


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