C++11 user-defined literals

Gabriel Dos Reis gdr at integrable-solutions.net
Wed Mar 7 01:39:33 CET 2012


On Mon, Mar 5, 2012 at 2:23 PM, Marc Glisse <marc.glisse at inria.fr> wrote:
> Hello,
>
> in C++11, we could make it so that writing 2_mpz or "-123/17"_mpq would be
> equivalent to mpz_class(2) or mpq_class("-123/17"). Does that seem useful to
> anyone? If it does, what suffix do you think would be best (like _mpz and
> _mpq in my example, with the constraint that it has to start with an
> underscore)?

I believe it is actually very useful (assuming you have a C++11 compiler such as
GCC-4.7.x) for reason you stated: is your integer literal does not fit
'unsigned long'
(and you would actually like to use 'long long' or 'unsigned long
long') you are kind
of stuck with the current (limited) interface.

-- Gaby


More information about the gmp-discuss mailing list