Reputation: 513
I am trying to add to the Eigen.natvis, found here, so that Eigen::Map
objects can also be read in the Visual Studio debugger, Eigen library found here.
Here is what I put together:
<Type Name="Eigen::Map<Eigen::Matrix<*,-1,-1,*,*,*>,*,*>">
<DisplayString Condition="m_data == 0">empty</DisplayString>
<DisplayString Condition="m_data != 0">Map[{m_rows.m_value}, {m_cols.m_value}] (dynamic matrix)</DisplayString>
<Expand>
<ArrayItems Condition="Flags%2"> <!-- row major layout -->
<Rank>2</Rank>
<Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>
<ValuePointer>m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="!(Flags%2)"> <!-- column major layout -->
<Direction>Backward</Direction>
<Rank>2</Rank>
<Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>
<ValuePointer>m_data</ValuePointer>
</ArrayItems>
</Expand>
</Type>
The main problem I am facing is with this line (discovered by trial and error):
<Size>$i==0 ? m_rows.m_value : m_cols.m_value</Size>
If, instead, I use any of the following then it works, but incorrectly of course (specific number constants are irrelevant):
<Size>$i==0 ? 4 : 2</Size>
<Size>$i==0 ? 3 : m_cols.m_value</Size>
<Size>$i==0 ? m_rows.m_value : 5</Size>
What am I missing? How do I get this to run correctly? Also, the natvis for Eigen::Matrix
does something similar and there it does work.
Upvotes: 1
Views: 991