how does templates work, are they always inlined?

后端 未结 6 1612
谎友^
谎友^ 2020-12-20 19:59

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

6条回答
  •  天命终不由人
    2020-12-20 20:36

    it's implementation dependent.

    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

提交回复
热议问题