Tom
Tom

Reputation: 7951

Visual Studio .natvis file - matrices

I'm trying to display a matrix class in the Visual Studio 2013 debugger. The relevant part of the class is this:

class mat {
private:
    size_t rowdim, coldim;
    double* _mem;
};

I'm trying to visualise this as a multi-dimensional array but I can't figure out how to specify the size of the dimensions when they're not stored as an array. This is what I'm trying:

<Type Name="mat">
    <DisplayString>{{ Matrix {rowdim}x{coldim} }}</DisplayString>
    <StringView>_mem,[rowdim]</StringView>
    <Expand>
        <Item Name="[size]" ExcludeView="simple" >rowdim</Item>
        <ArrayItems>
            <Direction>Forward</Direction>
            <Rank>2</Rank>
            <Size>{rowdim, coldim}</Size>
            <ValuePointer>_mem</ValuePointer>
        </ArrayItems>
    </Expand>
</Type>

But there doesn't seem to be any way of giving the dimensions as literals, or as distinct variables, only as an array to be indexed. Does anyone know if there's a way of doing this?

Upvotes: 3

Views: 1247

Answers (1)

TimVdG
TimVdG

Reputation: 2073

You can specify basic expressions and the debugger will evaluate them, try using:

<Size>$i == 0 ? rowdim : coldim</Size>

Visual studio 2015 accepts this, i don't have 2013 installed anymore.

Upvotes: 1

Related Questions