Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-04-24 13:40:39


Ed Brey wrote:
>
> From: "Jens Maurer" <Jens.Maurer_at_[hidden]>

> > Allowing constant folding (or not) is a quality-of-implementation
> issue
> > and should not affect the interface. (In particular, implementors
> > may choose to define the constants inline, but that's not what I'd
> > do for the generic boost implementation.)
>
> I agree that it's a QOI issue. All other things being equal, supporting
> constant folding makes the library higher-quality. Why wouldn't we want
> the boost library to have this quality? If not boost, where would one
> go to find an implementation with this quality? I presume that there is
> a tradeoff involved here, but I fail to see what it is,

Some compilers may emit all constants in each object file compiled
from a source file which includes <boost/math/constants.hpp>.
That's a weak claim, since I haven't tried it myself. Other than that,
defining the constants inline avoids dealing with the "library build"
issue at this point.

Btw, I'd prefer not to have constants in the sense of "const double x",
but (inline) functions returning the values. When defining interval
constants, for example, lots of interval constructors would be
(possibly needlessly) called when the compiler lays out the constant
class in the object file. The "only instantiated when used" paradigm
for template functions avoids that cost for unused constants.

Jens Maurer


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk