Walter Bright wrote:
Timothy Madden wrote:
Walter Bright wrote:
For one thing, it requires that the compiler maintain some sort of
global database of precompiled templates. Managing that database is a
time sink,
and comes with its own set of problems.
I have heard this idea before, but how is this required ?
If the compiler is compiling foo.cpp, and it contains an exported
template declaration, the compiler has no clue from the source code
where it might find that template definition.
Therefore, there must be some sort of global database the compiler can
consult and update.
The idea is the template definition is only needed at template
instantiation time. I will compile foo.cpp /without/ the template
definitions, and instead include the symbol table as it was at the end
of the unit, in the generated object file.
At the template instantiation phase (translation phase 8, a new step
between compiling and linking) the compiler has all the object files,
finds the pre-parsed template definition in one of them, and then
completes the compilation of foo.cpp using the stored symbol table to
compile the needed templates.
There is no such global database involved, except maybe for some
optimizations if you will.
whatever program implements step 8.
[ comp.lang.c++.moderated. First time posters: Do this! ]