GMP and C++11 move constructors

Marco Bodrato bodrato at mail.dm.unipi.it
Sun May 20 11:37:57 UTC 2018


Ciao,

Il Ven, 18 Maggio 2018 3:17 pm, Hans Åberg ha scritto:
>> On 18 May 2018, at 15:01, Marc Glisse <marc.glisse at inria.fr> wrote:
>> On Fri, 18 May 2018, Hans Åberg wrote:
>>
>>> FYI, if one follows the GMP API, it forces C++11 move constructors to
>>> make a heap allocation via mpz_init, which then is immediately

>> If you look at the current repository, you'll notice that mpz_init does
>> not perform a heap allocation anymore.
>
> But it looks like it isn't NULL, so I gather mpz_clear checks for that
> value, otherwise it will crash on 'free'.

Yes, you need to init an mpz, before clear-ing it. But, as Marc
underlined, this will not imply a heap allocation, with the current
development code.

I'm not an expert about C++, at all. Could you please write here how the
GMP_API forces to write the constructors you are speaking about, and how
you would like to write them instead?

Ĝis,
m

-- 
http://bodrato.it/papers/



More information about the gmp-discuss mailing list