Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-04-25 11:37:16

Ed Brey wrote:

> namespace boost { namespace math {
> template<typename T> struct constants {};
> template<> struct constants<float> {
> static float pi() {return 3.14F;}
> };
> template<> struct constants<double> {
> static double pi() {return 3.14;}
> };
> template<> struct constants<long double> {
> static long double pi() {return 3.14L;}
> };

Up to here we're in agreement.

> template<typename T> struct tailored_constants: constants<T> {};
> #ifdef PLATFORM1
> #endif


The "tailored_constants" stuff is needlessly complicating the interface,
because that means that the user would need to explicitly write
tailored_constants<T>::... wherever he wishes to get the really precise
constants. The precision of the constants is basically a Quality-of-
implementation issue for the constants<> template.

> typedef boost::math::constants<float> c;
> a = c::pi() * r * r;

You're not even doing it here.

The option for the implementor is to replace the constants<>
definition with what you propose for "tailored_constants".

> I wouldn't worry about the binary values for specific platforms at this
> time,


Jens Maurer

Boost list run by bdawes at, gregod at, cpdaniel at, john at