POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) : Re: A question about Java generics (not a flame) Server Time
7 Sep 2024 23:24:22 EDT (-0400)
  Re: A question about Java generics (not a flame)  
From: Warp
Date: 13 May 2008 15:58:54
Message: <4829f2fe@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.