简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM