I read that the latest versions of linkers filter out duplicate definitions in several translation units, there, referring to the problem of bloating code in relation to templates.
So, even if I use the compilation enable model, my code using templates should not inflate the code.
My request relates to the use of patterns (metaprogramming) as follows:
template <int N> int fact ()
{
return fact<N-1>() * N;
}
template <> int fact<1> ()
{
return 1;
}
int main()
{
cout << fact<10>() << endl;
}
The exe size for the above code is approximately 8K. If I pass 100 instead of 10, the code size increases to 19K.
I'm mainly trying to understand coding patterns that can lead to code bloat when using patterns.
EDIT: after Yakk's comment, I recompiled using -O3, now the size is almost the same.
, ( )?