3

The default visualiser for shared_ptr in VS2013 has this (many, many things trimmed out!):

<Type Name="CA::shared_ptr&lt;*&gt;">
  <Expand>
    <Item Condition="_Ptr != 0" Name="[ptr]">_Ptr</Item>
  </Expand>
</Type>

This means that in the debugger you have to expand the shared_ptr then expand the [ptr] 'member' to see the pointed-to object's members. The hierarchy for a pointer to int would look like (ignoring raw views, allocators and deleters):

myIntPtr
  [ptr]
    42

I'd like to write a replacement which places all the pointed-to object's members one level up, to sit at the level in the hierarchy where [ptr] currently sits. This would instead look like:

myIntPtr
  42

Is there some syntax that will allow that? I should note, I'm looking for general syntax to support displaying all of a template parameter's members, rather than something that will only work with shared_ptr - shared_ptr is just a handy example.

Ben Hymers
  • 25,586
  • 16
  • 59
  • 84

1 Answers1

3

I think this is what the "ExpandedItem" tag is good for. They even give an example that is similar to yours. See here: http://msdn.microsoft.com/en-us/library/jj620914.aspx#BKMK_ExpandedItem_expansion

mooware
  • 1,722
  • 2
  • 16
  • 25
  • Looks like you're right! I no longer have access to the code and natvis file this was about so can't test it in that context but the documentation does look spot-on! Thanks! – Ben Hymers Jan 19 '15 at 20:37
  • @BenHymers can you please take a look [here](https://stackoverflow.com/questions/72359355/extend-display-range-of-arrayitems-indexlistitems-using-natvis?noredirect=1#comment127858705_72359355). – user10634362 May 26 '22 at 09:18