Last active
November 17, 2015 17:28
-
-
Save tenpercent/cfba593e35406256fff3 to your computer and use it in GitHub Desktop.
pretty-printer for std::unique_ptr enabled for recursive printing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MUniquePointerPrinter: | |
""" Print a unique_ptr with pointed-to-value | |
credits: https://gcc.gnu.org/ml/libstdc++/2013-04/msg00098.html | |
""" | |
def __init__ (self, typename, val): | |
self.val = val | |
def to_string (self): | |
v = self.val['_M_t']['_M_head_impl'] | |
return ('std::unique_ptr<%s> containing %s' % (str(v.type.target()), | |
str(v))) | |
def children (self): | |
l_address = self.val['_M_t']['_M_head_impl'] | |
l_value = 'NULL' if l_address == 0 else l_address.dereference () | |
return iter([('<managed value>', l_value)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment