It should probably be emphasized that facilitating inlining is just
a by-product of templates. Moving a template around allows the template
to be re-interpreted in different contexts, and re-interpretation is really
the
key to code reuse.On Friday, October 30, 2015 at 7:59:18 PM UTC-4, gmhwxi wrote:
One consequence of template instantiation is bringing the definition of a
template to the place where
the template is used. In this way, it creates an opportunity of the C
compiler to actually perform inlining.A non-template function is still while a function template is mobile (in
the sense that its code gets moved
around by the ATS compiler).On Friday, October 30, 2015 at 7:26:51 PM UTC-4, Mike Jones wrote:
Ok, so you are saying using templates enables inlining, but does not
enforce it. You can always find a compiler setting to prevent it.I am basing this on a comment in another thread where I had a function
like u73 that clamped a value, and you suggested templates so that it would
be inlined.