
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 found at <http://boost-sandbox.sourceforge.net/vault/index.php?directory=daniel_frey> Regards, Daniel