Request for C++ interface doc improvement

Jerome L Quinn jlquinn at us.ibm.com
Thu Jul 31 14:53:35 UTC 2014



Marc Glisse <marc.glisse at inria.fr> wrote on 07/31/2014 02:07:02 AM:

> From: Marc Glisse <marc.glisse at inria.fr>
> To: Jerome L Quinn/Watson/IBM at IBMUS
> Cc: gmp-bugs at gmplib.org
> Date: 07/31/2014 02:07 AM
> Subject: Re: Request for C++ interface doc improvement
>
> https://gmplib.org/manual/C_002b_002b-Interface-Integers.html
>
> — Function: explicit mpz_class::mpz_class (const char *s, int base = 0)
> — Function: explicit mpz_class::mpz_class (const string& s, int base = 0)
>
> "explicit" is there...

Ah, this must have been added more recently.  I have gmp 4.3.1 on CentOS 6,
and "explicit" isn't there.

> > I'd like to suggest adding to the docs something like the following:
> >
> >
> > Conversions from `string' or `char*' do not happen automatically.
> > Construction must be explicit.  For example,
> >
> >    mpz_class a("245");
>
> You can also write that as:
>
> auto a = 245_mpz;

Unfortunately, I'm still in C++98 land, so that's not yet an option.

> Where in the docs do you think some extra text would help?

C++ General Interface

...

   Note that `bool' is not accepted directly, but must be explicitly
cast to an `int' first.  This is because C++ will automatically convert
any pointer to a `bool', so if GMP accepted `bool' it would make all
sorts of invalid class and pointer combinations compile but almost
certainly not do anything sensible.

<insert text here>

   Conversions back from the classes to standard C++ types aren't done
automatically, instead member functions like `get_si' are provided (see
the following sections for details).


More information about the gmp-bugs mailing list