C++11

Marc Glisse marc.glisse at inria.fr
Mon Sep 26 22:56:15 CEST 2011


On Mon, 26 Sep 2011, Hans Aberg wrote:

> On 26 Sep 2011, at 22:14, Marc Glisse wrote:
>> Just on the off chance that you are suggesting dropping expression templates and relying on copy elision and/or rvalue references to reduce the number of temporaries:
> Yes, but there would still be a template for the memory allocation.

I am sorry, I still don't understand what you are suggesting. What 
template are you talking about? Do you mean to implement integers of fixed 
size? Or is the template something like std::allocator? (this last option 
is not possible if we keep gmpxx as a "thin" wrapper to mp*_t)

>> I thought about it, but for things like a=b+c (a is a pre-existing variable), you won't be able to avoid creating a temporary, and for small numbers that's bad.
> C++11 has support for movable copy constructors, which would be used instead. One still needs to do a memory allocation, but must always be done.

I specifically said that a was a pre-existing variable, so this is an 
assignment, not a construction. In GMP terms, it means a simple call to 
mpz_add.

-- 
Marc Glisse


More information about the gmp-discuss mailing list