Boost logo

Boost :

From: Ken Hagan (K.Hagan_at_[hidden])
Date: 2003-06-20 05:26:58


Paul A Bristow wrote:
> This scheme may offer more surprises to the many naive users (like me)
> than an explicit (and convenient 'global') choice, for example:
>
> using boost::math::double_constants;
>
> to ensure that the expected size is used.
>
> One can make the compiler warn you about size conversions,
> whereas I have the impression that these rules will mean
> that you won't get any warnings.

AFAICT, you will either get exactly the type that the context requires,
or a diagnostic from the compiler saying that it is ambiguous. (This
assumes that a selection of possible types are available for each
constant.) I don't think it is possible to get a quiet conversion.

In contrast, "using boost::math::double_constants" does allow you
to get an implicit size conversion, where the context requires one.
Compilers will warn, but only if users haven't disabled the warning.

So, with the "clever" approach, all users will find themselves
writing a few explicit conversions to avoid ambiguities. With
the "simple" approach, only users who have their warning level
right up will need to write explicit conversions, and then only
to silence the compiler.

Listening to compiler warnings is something the community might
want to encourage (so the simple approach would then have no
advantages), but it isn't the job of a language standard to
mandate "good" programming practices. (In the absence of such
constraints, the definition of "good" tends to change with time.)


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