mpz_class initialization

Marc Glisse marc.glisse at inria.fr
Mon Mar 11 18:16:44 CET 2013


On Mon, 11 Mar 2013, Dmitry Panteleev wrote:

> For some reason mpz_class is initialized with 1-bit length assigned. Why it
> is not just zero-initialized, as soon as most(or all?) algorithms works
> well with such variables? It would be better for move semantics, which is
> now supported in gmp. Also then it will be possible to make default
> constuctor return constexpr.

This is discussed regularly on the GMP lists, sometimes as lazy 
initialization. Most functions are not currently ready for this, but it 
might happen some day. Most of the work needed is in the C layer, adapting 
the C++ wrapper would then be rather simple.

Boost.Multiprecision's mpz wrapper has a slightly different approach here, 
if you want to compare.

-- 
Marc Glisse


More information about the gmp-discuss mailing list