Dilip wrote:
I am stumbling my way through C++ templates and I keep running into
way too many questions. Here is one:
If a library writer exposes a function template like so:
template<typename T>
void some_func(T const& x)
{
}
Lets say the client code explicitly instantiates it:
template void some_func(int);
I don't think it's a match. What's "T" in this case?
Later if the library writer releases a new version that explicitly
specializes this template for the same data type, what happens to the
client code? The book I am reading says this issue is still pending
with C++ committee. Has there been any decisions taken?
You need to ask in 'comp.std.c++' about any Standard issues.
Or am I asking the question backwards? maybe client code is never
allowed to explicitly instantiate function/class templates from a
library?
The explicit instantiation makes sure that the code is created. Where
it comes from is the user's responsibility. Generally, if the instantiation
appears in the header, all TUs that include that header participate equally
in the contest to hold the actual generated code, and the linker possesses
the ablity to resolve that. Also, all instantiations have to be the same,
otherwise ODR is violated, and I don't know if nowadays the linkers actually
care to compare the instantiations. Usually the first one is picked. Which
of the several becomes "the first one" is undefined.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask