In the Visual Studio 2015 watch window, pointers can be watched as array by adding a comma and the array length, e.g. d,10 will display 10 elements for a double * d.
Is it possible to create a Natvis Type Entry which does this based on the number of indirections, ie. for d, d* and d** in a different way? Usually those are even members of a type, e.g. struct s { double* d }, but i want to avoid having to write custom visualizers for all those types.
The question is tagged for VS2015 but solutions for vs2017 or vs2019 are welcome if there are any.
Edit1: Here's a simple example of what i'm looking for:
struct S
{
double* v3;
double** m3;
};
int main()
{
double* pv3 = new double[3]{ -1,-2,-3 };
double** ppm3 = new double*[3]{ new double[3]{ 1,2,3 }, new double[3]{ 4,5,6 }, new double[3]{ 7,8,9 } };
S s;
s.v3 = pv3;
s.m3 = ppm3;
double v3[3] = { -1,-2,-3 };
double m33[3][3] = { { 1,2,3 }, { 4,5,6 }, { 7,8,9 } };
}
- pv3 and s.v3 should be visualized like v3 and
- ppm3 and s.m3 should be visualized like m33
I know that treating every double pointer as a double[3] might not be what everyone would want but in certain codebases like the one i'm working on this is the 99% usecase.