Marc Glisse marc.glisse at inria.fr
Mon Sep 26 22:14:41 CEST 2011

On Mon, 26 Sep 2011, Hans Aberg wrote:

> On 25 Sep 2011, at 20:00, Marc Glisse wrote:
>> If you have comments on the approach, or on other C++11 features that would help... (note that there are still many improvements possible without using new C++ features, which have a higher priority)
> It might be possible to implement ordinary classes (integer, rational, ...) without runtime overhead. This would be easier to use.

I am sorry, I don't understand what you mean.

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: 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.

That doesn't mean such a C++ wrapper to gmp would be a bad idea. There are 
many wrappers that make sense in various contexts:
- expression template like gmpxx
- value-based (as described above)
- reference counting
and variants optimizing for small numbers (which could also be done at the 
C level), etc.

There are even cases where the value-based version would have less 
temporaries than the current gmpxx (I have patches to remedy that, but no 
time to polish them right now).

And when a temporary mp*_class (likely returned from a user-defined 
function, or explicitly std::moved) is used in an expression, we could 
take advantage of that, without removing expression templates for 
"regular" code.

Marc Glisse

More information about the gmp-discuss mailing list