Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2001-10-24 17:05:54

> -----Original Message-----
> From: Greg Colvin [mailto:gcolvin_at_[hidden]]
> Sent: Wednesday, October 24, 2001 6:59 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Math constants for naive and gurus? - which
> constants do you want?

> Michael's code was rejected by EDG in strict mode, but is easily fixed.
> The following version EDG believes to be conforming C++:
> template< typename Rep, typename Tag >
> struct constant {
> constant(){}
> operator Rep() const; // fully specialized for each Rep/Tag pair
> };
> struct pi_tag {};
> template<> inline constant< float, pi_tag >::operator float() const {
> return 3.141592653589793238462643383279502884197F;
> }
> template<> inline constant< double, pi_tag >::operator double() const {
> return 3.141592653589793238462643383279502884197;
> }
> namespace float_constants {
> constant< float, pi_tag > const pi;
> }
> namespace double_constants {
> constant< double, pi_tag > const pi;
> }

Is the constructor constant REQUIRED?

Ed Brey pointed out:

"The reason is that it appears that those in tst.cpp lead to code bloat,
since I noticed that even unused constants ended up in the assembly listing
for a test program, and I doubted that the linker would always be able to
remove them, especially if creating a dynamicly linked library on platforms
where classes are not individually targeted for export."

So I removed the statement "constant() {}".

Is this what EDG in strict mode requires? If so have you any idea why?

Is order of typename Rep, typename Tag important?
(The original was changed to allow provision of a default - unnecessary, and
indeed undesirable, IMO).
Or is removal of the default typename Rep = double > the key requirement.
Have you any idea why?

Or is the some other difference that I have missed?


PS Your code also compiles OK with MSVC 6 WITHOUT the constant(){} null

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