public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: tuple pretty printer
       [not found] <CAOPLpQeEjCvdjsEpy-4BKPAA-gY5X=bD5niuQ1fXf=-44-2HxQ@mail.gmail.com>
@ 2022-08-04 11:03 ` Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-08-04 11:03 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: libstdc++, gcc Patches

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)
>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-04 11:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAOPLpQeEjCvdjsEpy-4BKPAA-gY5X=bD5niuQ1fXf=-44-2HxQ@mail.gmail.com>
2022-08-04 11:03 ` tuple pretty printer Jonathan Wakely

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).