is there a way to know the compiler instantiated code for a template function or a class in C++
Assume I have the following piece of code
template &l
I think c++ Insights is what you want.
Now there is an on-line tool which does this for you: https://cppinsights.io/ For example, this code
template<class X, class Y> auto add(X x, Y y) {
return x + y;
}
int main()
{
return add(10, 2.5);
}
Is translated to
template<class X, class Y> auto add(X x, Y y) {
return x + y;
}
/* First instantiated from: insights.cpp:9 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
double add<int, double>(int x, double y)
{
return static_cast<double>(x) + y;
}
#endif
int main()
{
return static_cast<int>(add(10, 2.5));
}