Reputation: 210745
How do I get std::pair<char *, char *>
to display as a proper string segment in Visual Studio, rather than as two pointers to null-terminated strings?
Upvotes: 1
Views: 365
Reputation: 210745
Create %UserProfile%\Documents\Visual Studio 2015\Visualizers\custom.natvis
(replace 2015
with your version of Visual Studio, obviously) and then try something like the following:
<?xml version='1.0' encoding='utf-8'?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- For more information on how to create debugger visualizers, refer to:
https://msdn.microsoft.com/en-us/library/jj620914.aspx
https://msdn.microsoft.com/en-us/library/75w45ekt.aspx
-->
<Type Name="std::pair<*,*>">
<DisplayString Condition="*second - *first >= 0">{first,[second - first]}</DisplayString>
</Type>
<Type Name="std::pair<*,*>">
<DisplayString Condition="*second._Ptr - *first._Ptr >= 0">{first._Ptr,[second._Ptr - first._Ptr]}</DisplayString>
</Type>
</AutoVisualizer>
Result:
Upvotes: 1