E2<T>
is a smart pointer.
To enable a tool-tip of E2<T>->aField
when mouse hovers above it, I can create .natvis
like :-
.cpp
class Blank{
public: int sss=5;
};
template<class T> class E2 {
public: T* operator->(){
return static_cast<T*>(atDerive);
}
T* atDerive; //#
};
int main(){
Blank k2; k2.sss=32;
E2<Blank> e2;
e2.atDerive=&k2;
e2->sss=4;
}
.natvis
<Type Name="E2<*>">
<SmartPointer Usage="Minimal">atDerive</SmartPointer>
</Type>
Result
Problem
The above approach doesn't work if the content void*
is in the base class E1
.
.cpp
class E1{
public: void* atBase=nullptr; //#
};
template<class T> class E2 : public E1{
public: T* operator->(){
return static_cast<T*>(atBase);
}
};
int main(){
Blank k; k.sss=31;
E2<Blank> e2;
e2.atBase=&k;
e2->sss=4;
}
.natvis (not work - no tool-tip appear)
<Type Name="E2<*>">
<SmartPointer Usage="Minimal">atBase</SmartPointer>
</Type>
Question
How to modify .natvis
to enable tool-tip to show void*
that is in the base class (E1
)?
Add a type cast from
void*
to template typeT
(you can get it as a $T1 in your .natvis file)