gmpxx implicit conversion between types
Marc Glisse
marc.glisse at inria.fr
Wed Mar 9 09:27:01 CET 2011
On Wed, 9 Mar 2011, Joerg Arndt wrote:
> * Torbjorn Granlund <tg at gmplib.org> [Mar 08. 2011 20:27]:
>> When dealing with "heavy" types like these, is it in the C++ spirit to
>> allow implicit conversions? Will we do any good by disallowing them?
>
> Implicit: as few as possible.
>
> A good guidance are computer algebra systems. E.g.:
> Divide an integer by an integer ==> rational
It's too late for that one, mpz_class has euclidean / and % operations,
and it's useful to have a type with this behavior.
> Any operation of type with float ==> float.
Any operation with an mpf yields an mpf. On the other hand, mpz+double
gives a mpz (just describing the current situation here).
> Another thing (if not already done):
> make _all_ constructors "explicit".
Constructors from a string or a mp*_srcptr are already explicit.
Constructors from int (and the likes) are implicit, and I can't really see
anything wrong with that.
--
Marc Glisse
More information about the gmp-discuss
mailing list