From patchwork Thu Dec 22 12:44:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v3] libstdc++/48362 - pretty printer for std::tuple<> with no elements From: Jonathan Wakely X-Patchwork-Id: 132841 Message-Id: To: "libstdc++" , gcc-patches Date: Thu, 22 Dec 2011 12:44:39 +0000 PR libstdc++/48362 * python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle empty tuples. There might be a neater way to fix this, but this does the job. Committed to trunk. Index: python/libstdcxx/v6/printers.py =================================================================== --- python/libstdcxx/v6/printers.py (revision 182619) +++ python/libstdcxx/v6/printers.py (revision 182620) @@ -251,11 +251,11 @@ class StdTuplePrinter: # Set the base class as the initial head of the # tuple. nodes = self.head.type.fields () - if len (nodes) != 1: + if len (nodes) == 1: + # Set the actual head to the first pair. + self.head = self.head.cast (nodes[0].type) + elif len (nodes) != 0: raise ValueError, "Top of tuple tree does not consist of a single node." - - # Set the actual head to the first pair. - self.head = self.head.cast (nodes[0].type) self.count = 0 def __iter__ (self): @@ -297,6 +297,8 @@ class StdTuplePrinter: return self._iterator (self.val) def to_string (self): + if len (self.val.type.fields ()) == 0: + return 'empty %s' % (self.typename) return '%s containing' % (self.typename) class StdStackOrQueuePrinter: