For a template defined as:
struct sameT{};template <class T>void print(){/*do stuff*/}int main(){ print<sameT>(); print<sameT>();}
When I watched the machine code generated by gcc for above code, there was exactly same 2 function with same content for print. I had expected this only when i had done
print<type1>();print<type2>();
Wouldn't the compiler supposed to generate a single bunch of assembly per type. I mean to use the same function twice for both print<int>()
. What am I missing?