J
James Kanze
So let's assume we have a concrete type (stand alone class),
e.g. a complex class. And we don't use all its member
functions in a program, why should we have them imposed to us?
If it's in the application, there's no reason to write any
function which isn't used. If it's in a library, which is used
by several applications, you put each function in a separate
source file, and each application only contains the code it
uses.
You seem to be confusing instantiation and presence in the
client program. Instantiating a template means expanding it for
a specific set of template arguments, converting the function
template into a function. Instantiation has no meaning for non
template functions, since they are already "functions". Whether
a function (resulting from a template instantiation or not) is
incorporated into the application is a completely different
question (except that function templates which have not been
instantiated obviously cannot be incorporated into the
application, since there is no function to incorporate). How
you specify which functions are incorporated into the final
application is implementation defined: if the function is in a
library, it will only be incorporated if the application uses
something in the object file it resides in (and I think in some
cases, only if the function is actually used). Normally, when
writing a library, you put each function in a separate source
file, which means that each function ends up in a separate
object file, which means that a function will only end up in the
application if it is actually used.