C++11
Hans Aberg
haberg-1 at telia.com
Mon Sep 26 23:16:58 CEST 2011
On 26 Sep 2011, at 22:56, 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?
Right.
> (this last option is not possible if we keep gmpxx as a "thin" wrapper to mp*_t)
This would be a different wrapper.
>>> 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.
There is a move assignment operator as well (I just skipped the details). It is called rvalue references.
Hans
More information about the gmp-discuss
mailing list