Subject: Re: [boost] [Review Request] Multiprecision Arithmetic Library
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-04-06 03:33:15
>So, let me get this straight. The instantiation of a template such as
>get_constant_ln2() causes the compiler to notice that it needs to
>instantiate one (and only one) instantiation of template "long_type"::init
>in the first translation unit in which it is encountered. C++ has a
>one-time deal for template instantiation of non-local class-type statics,
>and the thing ends up being initialized once with ctor code in the
>Is that what you are talking about?
I think so ;-)
>OK. But finally, what if we bombard get_constant_ln2() with an MP
>type of run-time dynamic precision, first with 100 decimal digits,
>then with 200 decimal digits? Who tells get_constant_ln2() that it
>needs to re-calculate ln2? Or is this just a matter of documentation,
>saying, in effect, "don't do this!".
For cpp_dec_float they're all different types, so
cpp_dec_float<50> instantiates a different set of templates (and different
value/cache for ln2) to cpp_dec_float<100>.
mpf_float<0> is the only type we have that has variable precision at
runtime, and the std lib routines that call these constants aren't supported
in that use case (which should be documented somewhere - I'll check). And
they're not supported largely because of the caching mechanism. You should
get a compiler error if you try and use that type with those templates, but
I'll double check that.
PS Although it's possible to support variable runtime precision, it
complicates things enough not to support it unless folks get really worked
up about it ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk