I can understand how it work if they are inlined. But if they are not, how does it work? does all object files get their own copy of for example the function template anyway
But commononly, yes each object file gets a copy of each expanded function they use.
And then the linker notices this at link time and ensures that only one copy of the function gets put in the final executable file