From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-06-24 04:24:26
I have now been able to try your suggestions using MSVC 7.1 (rather than the
undoubtedly better Intel 7.1 version (was KAI?))
cout << (float) math::pi etc are OK
(though does this imply that every use of pi need to include the cast?
This would NOT be at all popular because it would obscure the meaning of
With Kenniston's namespace one can simply declare "I'm only using doubles" with
using namespace boost::math::double_constants;
Alas, the area example doesn't work because MSVC 7.1 does not resolve the
std::cout << "Area (float) = " << area(1.0F) << std::endl; // <<<< Note float
Sletteboe_constants1.cpp(35) : error C2593: 'operator *' is ambiguous
could be 'built-in C++ operator*(float, float)'
or 'built-in C++ operator*(int, float)'
or 'built-in C++ operator*(double, float)'
or 'built-in C++ operator*(long double, float)'
while trying to match the argument list '(const boost::math::pi_type,
Sletteboe_constants1.cpp(40) : see reference to function template
instantiation 'T area<float>(T)' being compiled
Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]]On Behalf Of Terje Slettebø
| Sent: Sunday, June 22, 2003 2:33 AM
| To: Boost mailing list
| Subject: Re: [boost] Math Constants Formal Review
| This is tested on Intel C++ 7.1, but it should work on most compilers,
| especially if workarounds are applied, if needed.
| As shown, this works well with generic code, like the "area()" function.
| My question is: Is there any reason why it can't be done this simple?
| Note that there are no extra classes or functions needed. There's only the
| class representing the constant, and the templated conversion operator, and
| any specialisations of it. This should be trivial for a compiler to inline,
| and should also be easy to examine with a debugger (an issue that also has
| come up).
| This is very easy to extend with new constants and types. It's an open-ended
| It uses macros for easy definition of constants and their values for
| different types, for easy definition (just like Kenniston's and Daniel's
| The above addresses the presentation of the constants (their interface), as
| identified by Paul as one of the primary objectives. What values that are
| used in the definitions is orthogonal to this.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk