From: Daniel Frey (d.frey_at_[hidden])
Date: 2005-05-08 05:52:23
John Maddock wrote:
>>> Static constants in "<type>_constants"-namespaces are also
>>> undesirable, because there is no way to select a namespace named
>>> "<T>_constants" from within a template.
>> FWIW thi would work fine for me:
>> typedef std::math::constants<T> math;
>> 2 * math::pi * r ;
> Except you can't then add new constants without changing the definition
> of math_constants. If you use a namespace for the "container" and
> free-standing template functions, then you can either:
> Add new constants.
> Add support for new types.
> Without changing the existing code.
These problems (and many more) are already solved by the constants
library I wrote some time ago. The weak points are: No documentation yet
and I use typeof, although a great deal of functionality can be
preserved without typeof. I think I should work on these two points, but
till then, you might want to look at the current version, complete with
examples for physical constants supporting unit-libraries! It can be
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk