Do patterns reduce the size of the source or binary, or both

I read that templates are executed in different entities, so does this mean that the size of the binary file will be the same as we performed using different functions?

+5
source share
5 answers

They should reduce the size of the source (if they are reused), but not the binary size (the template is compiled for every other instance).

This differs from Java generics, where there is full-type erasure (generics are only used to check type compilation time) or C #, where generic files are compiled into certain binary files that can be reused repeatedly without having to recompile and generate more code.

+5

, , , complier - , List<int>, List<foo> List<float>, List .

Edit:
, , () , .

+2

... , .

, , - , , , , , , ( ), , " ".

+2

, , , redandant.

, .

0

Templates will certainly be a way to write more general and shorter code. Instead of writing your function blahn times to deal with different types of parameters, you write it once with the typical type for the parameter.

As for the binary size, the code will be created for the instances you create, that is, when specifying the type. I do not see how this will reduce the size of the binaries.

0
source

All Articles