Boost C++ Libraries: Ticket #10112: improved shared_ptr visualizer and weak_ptr https://svn.boost.org/trac10/ticket/10112 <p> I was trying out the boost::shared_ptr visualizer for Visual Studio 2010, here <a class="ext-link" href="https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/shared_ptr.vis.txt"><span class="icon">​</span>https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/shared_ptr.vis.txt</a> </p> <p> It's ok, but it doesn't show very much. The typical display is: </p> <p> shared_ptr {...} count = ... </p> <p> While experimenting with the visualizer, I made several observations: </p> <p> 1) If you view a pointer rather than a dereferenced pointer, you see both the address (which is useful) and more content in the referenced object (which is very useful) </p> <p> 2) Our normal use of shared_ptr is as a pointer. The usage count is not normally something we want to know about. By removing the text formatting, and only showing the pointer in the preview, we see far more content in the referenced object (even more useful) </p> <p> 3) The children are displayed in alphabetic order. It's most useful to be able to see and expand "ptr" in the children. Renaming "count" to "use_count" puts "ptr" at the top, where it belongs. </p> <p> 4) weak_ptr can be visualized the same way. </p> <p> An example boost::shared_ptr is now previewed as: </p> <p> 0x18467058 {parent_bond_=0x184546e0 {type_={...} polymeric_=false annotations_={...} ...} mol_=0x18448768 {m_=0x1246c5ac {impl_={...} annotations_={...} } impl_={...} proxy_atom_creator_={...} ...} graphic_properties_=0x00000000 } </p> <pre class="wiki">;------------------------------------------------------------------------------ ; boost::shared_ptr ;------------------------------------------------------------------------------ boost::shared_ptr&lt;*&gt;{ preview ( ($T1 *)$c.px ) children ( #( ptr: (($T1 *)$c.px) , use_count: $c.pn.pi_-&gt;use_count_ , weak_count: $c.pn.pi_-&gt;weak_count_ ) ) } ;------------------------------------------------------------------------------ ; boost::weak_ptr ;------------------------------------------------------------------------------ boost::weak_ptr&lt;*&gt;{ preview ( ($T1 *)$c.px ) children ( #( ptr: (($T1 *)$c.px) , use_count: $c.pn.pi_-&gt;use_count_ , weak_count: $c.pn.pi_-&gt;weak_count_ ) ) } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10112 Trac 1.4.3 anonymous Wed, 11 Jun 2014 11:13:22 GMT <link>https://svn.boost.org/trac10/ticket/10112#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10112#comment:1</guid> <description> <p> Seems to be better still if you use $e rather than $c - iterators and function returns are now expanded. </p> <pre class="wiki">;------------------------------------------------------------------------------ ; boost::shared_ptr ;------------------------------------------------------------------------------ boost::shared_ptr&lt;*&gt;{ preview ( ($T1 *)$e.px ) children ( #( ptr: (($T1 *)$e.px) , use_count: $e.pn.pi_-&gt;use_count_ , weak_count: $e.pn.pi_-&gt;weak_count_ ) ) } ;------------------------------------------------------------------------------ ; boost::weak_ptr ;------------------------------------------------------------------------------ boost::weak_ptr&lt;*&gt;{ preview ( ($T1 *)$e.px ) children ( #( ptr: (($T1 *)$e.px) , use_count: $e.pn.pi_-&gt;use_count_ , weak_count: $e.pn.pi_-&gt;weak_count_ ) ) } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Matias Capeletto</dc:creator> <pubDate>Mon, 02 Feb 2015 16:44:25 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/10112#comment:2 https://svn.boost.org/trac10/ticket/10112#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Matias Capeletto</span> to <span class="trac-author">fkonvick</span> </li> </ul> Ticket viboes Fri, 13 Feb 2015 18:36:55 GMT component changed https://svn.boost.org/trac10/ticket/10112#comment:3 https://svn.boost.org/trac10/ticket/10112#comment:3 <ul> <li><strong>component</strong> <span class="trac-field-old">Documentation</span> → <span class="trac-field-new">smart_ptr</span> </li> </ul> Ticket