From: Jonathan Wakely <jwakely@redhat.com>
To: Ulrich Drepper <drepper@gmail.com>
Cc: libstdc++@gcc.gnu.org, gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: tuple pretty printer
Date: Thu, 4 Aug 2022 12:03:27 +0100 [thread overview]
Message-ID: <CACb0b4=UdsYSv3MzaJMOh-6iXU1vN-oMZqEL5-+V0tp_4K5beA@mail.gmail.com> (raw)
In-Reply-To: <CAOPLpQeEjCvdjsEpy-4BKPAA-gY5X=bD5niuQ1fXf=-44-2HxQ@mail.gmail.com>
CC gcc-patches
On Wed, 27 Jul 2022 at 17:40, Ulrich Drepper via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> The current tuple pretty printer shows for this variable
>
> std::tuple<int,int,int> a{1,2,3};
>
> the following output:
>
> (gdb) p a
> $1 = std::tuple containing = {[1] = 1, [2] = 2, [3] = 3}
>
> I find this quite irritating because the indices don't match the
> std::get template parameters. In a large tuple or arrays of tuples
> which are less readable than this simple example this becomes an even
> larger problem. How about the following simple patch which brings the
> indices in line?
I think this makes sense, want to push it?
>
> --- a/libstdc++-v3/python/libstdcxx/v6/printers.py
> +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
> @@ -611,9 +611,9 @@ class StdTuplePrinter:
> # the value "as is".
> fields = impl.type.fields ()
> if len (fields) < 1 or fields[0].name != "_M_head_impl":
> - return ('[%d]' % self.count, impl)
> + return ('[%d]' % (self.count - 1), impl)
> else:
> - return ('[%d]' % self.count, impl['_M_head_impl'])
> + return ('[%d]' % (self.count - 1), impl['_M_head_impl'])
>
> def __init__ (self, typename, val):
> self.typename = strip_versioned_namespace(typename)
>
prev parent reply other threads:[~2022-08-04 11:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 16:40 Ulrich Drepper
2022-08-04 11:03 ` Jonathan Wakely [this message]
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='CACb0b4=UdsYSv3MzaJMOh-6iXU1vN-oMZqEL5-+V0tp_4K5beA@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=drepper@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/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).