|
|
Darren New <dne### [at] sanrrcom> wrote:
> But if in A.cpp I have xyz:MyTemplate<T> and in the body of MyTemplate
> it invokes T.x(i), isn't the code generated going to depend on the
> declarations of T.x that are available at the point I instantiate the
> template? If x is an overloaded function, doesn't it have to know all
> the overloaded functions in scope to pick the one most likely to be the
> one I meant by passing whatever type "i" is?
I can't think of any way how a certain type T can change in different
compilation units without causing a linker error.
If you have a class T, it will have a certain declared interface. That
interface doesn't change depending on the context. If you give the template
some other class, for example one derived from T, that's a *different* type,
and thus requires its own instantiation of the template function.
--
- Warp
Post a reply to this message
|
|