Are templated functions always re-constructed?

Mike Parker aldacron at
Wed Nov 17 02:50:43 UTC 2021

On Tuesday, 16 November 2021 at 21:14:50 UTC, rempas wrote:
> Let's say that I have the following function:
> ```
> void add(T)(T val, T val2) { return val + val2; } // Classic 
> example, lol
> ```
> Now let's say that I call the function passing an `int` 
> parameter. The function will get built with an `int` type. What 
> happens the second time that I will call it again? Will it get 
> the already build function or will it make a new one? I suppose 
> it re-uses it but still I wanted to ask just in case. Please 
> only answer if you are sure and not be making guesses because 
> it is really important! Thanks!

You might find this useful:

More information about the Digitalmars-d-learn mailing list