![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Sat, 17 May 2008 10:36:31 +0200, Warp <war### [at] tag povray org> wrote:
> Sorry, I still don't understand this.
>
> I tried my foo-bar example making the bar() function a template which
> was
> specialized in one of the compilation units but not the other, and at
> least
> gcc still behave in the same way: When foo() was not inlined, only one
> version of bar() was called: The specialized version was never called.
Your foo-bar example is ill-formed. The compiler can do whatever it wants.
> From what you have written it sounds like the compiler would have to
> always call the specialized bar() template if it is in the context of
> the foo() instantiation, but at least gcc doesn't behave this way (and,
> frankly, I don't know *how* it could behave that way without seriously
> messing things up).
It is commonly called "two-phase lookup" (though it is not named as such
in the standard) and is explained in section 14.6 [temp.res] of the
standard. Section 14.6.4 [temp.dep.res] deals specifically with dependent
name resolution.
Compiler writers have been rather slow in implementing two-phase lookup
properly, almost as slow as with implementing 'export'.
--
FE
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
From: Warp
Subject: Re: A question about Java generics (not a flame)
Date: 17 May 2008 07:41:18
Message: <482ec45e@news.povray.org>
|
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> On Sat, 17 May 2008 10:36:31 +0200, Warp <war### [at] tag povray org> wrote:
> > Sorry, I still don't understand this.
> >
> > I tried my foo-bar example making the bar() function a template which
> > was
> > specialized in one of the compilation units but not the other, and at
> > least
> > gcc still behave in the same way: When foo() was not inlined, only one
> > version of bar() was called: The specialized version was never called.
> Your foo-bar example is ill-formed. The compiler can do whatever it wants.
How is it different from your example, which you gave earlier? Also you
had a template function calling another template function, and the latter
being specialized in the context of instantiating the former. That's exactly
what I did.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Sat, 17 May 2008 13:41:18 +0200, Warp <war### [at] tag povray org> wrote:
> Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
>> Your foo-bar example is ill-formed. The compiler can do whatever it
>> wants.
>
> How is it different from your example, which you gave earlier? Also you
> had a template function calling another template function, and the latter
> being specialized in the context of instantiating the former. That's
> exactly what I did.
The difference is that you are instantiating 'foo<int>' in more than one
place. When you do that, the instantiations must have the same meaning or
the program is ill-formed. In my example 'f<int>' is only instantiated
once. That example was intented only to demonstrate why an exported
template must be recompiled when code that uses it is changed.
--
FE
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |