public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Pedro Alves <pedro@palves.net>
Cc: gdb@sourceware.org,  "Zaric, Zoran (Zare)" <Zoran.Zaric@amd.com>
Subject: Re: gmp's c++ interface / mpz_class
Date: Wed, 19 Oct 2022 12:28:53 +0200	[thread overview]
Message-ID: <87lepcgl96.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <f2bb71e9-2ac1-1540-5d94-6807c540b23e@palves.net> (Pedro Alves's message of "Fri, 14 Oct 2022 21:42:10 +0100")

* Pedro Alves:

> Hmm.  Since we don't need infinite precision, it will end up a lot
> more efficient to roll our own type, with fixed (or templated) storage
> size.  Like a simplified version of GCC's wide_int.  Not sure yet
> whether efficiency really matters in practice, but I suspect it does.
>
> I'd still be curious about GMP's native C++ interface.

I tried to use it recently in a hobby project, but it turned out to be a
poor fit because it's not integrated well with C++11 and later features
(no move constructors, no rvalue references).  The unconditional use of
malloc is rather off-putting, too.

I'm contemplating to use tagged integers/pointers as the main
representation, with heap allocation only on demand, maybe using the the
mpn* functions directly, or perhaps copy things out of a long-lasting
mpz_t object that's used as a temporary for arithmetic.

For 72-bit integers, that seems a bit over the top, though.

Thanks,
Florian


  reply	other threads:[~2022-10-19 10:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 18:11 Pedro Alves
2022-10-14 20:42 ` Pedro Alves
2022-10-19 10:28   ` Florian Weimer [this message]
2022-10-17 10:44 ` Luis Machado
2022-10-17 11:29   ` Pedro Alves
2022-10-17 17:21 ` Tom Tromey
2022-10-24 13:34   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lepcgl96.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=Zoran.Zaric@amd.com \
    --cc=gdb@sourceware.org \
    --cc=pedro@palves.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).