Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2001-03-28 06:04:42


Since nobody has posted a solution to this, I have devised a draft for
comments.

Only a couple of constants implemented for clarity of the concept.

There are four (types of) header files

1 .h C style preprocessor #define files with ~define _PI = 31.1459...L
2 .h C style preprocessor #undef _PI files (do avoid name clash problems).
3 .hpp C++ template function as below.
4 .hpp C++ const long double variables const long double pi = 31.1459...L.
5 .hpp C++ const double version, perhaps?

the two .hpp files both include #define file 1 at the start and end with the
#undef file 2.

I foresee 3 ways of using the files.

1 #include preprocessor #define _PI files and use these directly, C
programs mainly.

2 Use #include file for extern long double const pi; (static?)

3 Use template function math_constants<float>pi() as suggested below:

> > -----Original Message-----
> > From: k.hagan_at_[hidden] [mailto:k.hagan_at_[hidden]]
> > Sent: Tuesday, February 13, 2001 9:52 AM
> > To: boost_at_[hidden]
> > I still don't like the namespace pollution that #define causes.
> > What was the objection to something like...?
> >
> > template<class T> struct math_constants /*==namespace*/
> > {
> > static T e() { return T(_PI); }
> > };

 If this meets peoples requirements, I will undertake the more arduous task
of generating the constants as #define _PI = 3.1459...L etc.

A working example of the files attached (concatentated). I will copy a MSVC
6 SP4 version to the vault if requested.

Comments please!

Paul

PS Do we want to split the .hpp files into two (or more) groups, one for
basic constants and another for the more esoteric/exotic/erotic?
(I would want to keep the .h files the same for simple maintenance).

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