This may potentially be related to #217, since it's an inconsistency between Visual Studio and WinDbg.
I have a required use case in the Boost.Unordered library. In order to display the associative containers, I have a setup that boils down to this:
- A class template
- I need to detect properties about the type stored in the class from within the NatVis, so I can normalize it regardless of the type
- I'm doing this with a
<Intrinsic> elements that are "overloaded", using the attribute Optional="true"
- This is effectively doing "substitution failure" with NatVis, to ensure only 1 overload is alive at any given time
Here is a very boiled-down example of the kind of thing I need. I need to normalize inner for various types it could possibly be, and extract its value, so that value can be used in other places in the visualization homogeneously.
#include <optional>
template <typename PointerLike>
struct MyStruct
{
using InnerType = PointerLike;
InnerType inner;
};
int main()
{
int x = 5;
MyStruct<int*> a{ &x };
MyStruct<std::optional<int>> b{ x };
} // break here
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="MyStruct<*>">
<!--
The expression `&**p` is used so the Intrinsic fails to parse for anything other than a raw pointer.
For a raw pointer, this expression is exactly equivalent to `*p`.
For an optional, this expression will try to call a user-defined `operator*()`, which is not allowed in Natvis, and it will fail.
-->
<Intrinsic Name="get_pointer" Optional="true" Expression="&**p">
<Parameter Name="p" Type="InnerType*" />
</Intrinsic>
<Intrinsic Name="get_pointer" Optional="true" Expression="&(p->_Value)">
<Parameter Name="p" Type="InnerType*" />
</Intrinsic>
<Expand>
<Item Name="value">*get_pointer(&inner)</Item>
</Expand>
</Type>
</AutoVisualizer>
This is fully supported in Visual Studio, however when I try to use cdb.exe, this does not work.
I would be happy to go into more detail to explain the use case further. Thank you!
This may potentially be related to #217, since it's an inconsistency between Visual Studio and WinDbg.
I have a required use case in the Boost.Unordered library. In order to display the associative containers, I have a setup that boils down to this:
<Intrinsic>elements that are "overloaded", using the attributeOptional="true"Here is a very boiled-down example of the kind of thing I need. I need to normalize
innerfor various types it could possibly be, and extract its value, so that value can be used in other places in the visualization homogeneously.This is fully supported in Visual Studio, however when I try to use
cdb.exe, this does not work.I would be happy to go into more detail to explain the use case further. Thank you!