I need to use smart pointers for an application which has several hierarchy of classes. One difficulty while debug the code is the view of smart pointers (e.g. unique_ptr) inside the watch windows of Visual Studio 2015. It always shows [ptr], [deleter] and [Raw View]at the same time, while I mostly care about seeing quickly the content of [ptr] when expanding the view for the pointer. Is there a way to make debugging easier and customize the view of displaying the content of smart pointer to become same as raw pointers in visual Studio 2015? I know that this should be doable by using the appropriate NavisFile, however I don't know how should the following NavisFile be modified to show the content of [ptr] ?
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="std::unique_ptr<*>">
<SmartPointer Usage="Minimal">_Mypair._Myval2</SmartPointer>
<DisplayString Condition="_Mypair._Myval2 == 0">empty</DisplayString>
<DisplayString Condition="_Mypair._Myval2 != 0">unique_ptr {*_Mypair._Myval2}</DisplayString>
<Expand>
<Item Condition="_Mypair._Myval2 != 0" Name="[ptr]">_Mypair._Myval2</Item>
</Expand>
</Type>
</AutoVisualizer>
I am no expert, but it seems like you could simply remove the <Expand> node, and then change the second <DisplayString> to display just _Mypair._Myval2, eg:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="std::unique_ptr<*>">
<SmartPointer Usage="Minimal">_Mypair._Myval2</SmartPointer>
<DisplayString Condition="_Mypair._Myval2 == 0">empty</DisplayString>
<DisplayString Condition="_Mypair._Myval2 != 0">_Mypair._Myval2</DisplayString>
</Type>
</AutoVisualizer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With