Как получить std :: pair & lt; char *, char * & gt; отобразить как правильный сегмент строки в отладчике Visual Studio?

Как я могу получить std::pair<char *, char *> отображать как правильный сегмент строки в Visual Studio, а не как два указателя на строки с нулевым символом в конце?

1

Решение

Создайте %UserProfile%\Documents\Visual Studio 2015\Visualizers\custom.natvis (заменить 2015 с вашей версией Visual Studio, очевидно), а затем попробуйте что-то вроде следующего:

<?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&lt;*,*&gt;">
<DisplayString Condition="*second - *first &gt;= 0">{first,[second - first]}</DisplayString>
</Type>
<Type Name="std::pair&lt;*,*&gt;">
<DisplayString Condition="*second._Ptr - *first._Ptr &gt;= 0">{first._Ptr,[second._Ptr - first._Ptr]}</DisplayString>
</Type>
</AutoVisualizer>

Результат:

Скриншот

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector