[Issue 8850] Nested struct creation by a template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 7 09:55:22 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8850


timon.gehr at gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


--- Comment #6 from timon.gehr at gmx.ch 2012-11-07 09:55:21 PST ---
(In reply to comment #5)
> (In reply to comment #3)
> > I think it is supposed to work, the following does work:
> 
> In Currently, I answer: No.
> Even if TemplateTypeParameter gets nested struct type, a template instantiation
> will not capture the enclosing scope frame of the nested struct. It is intended
> behavior.
> 

On second thought, you are right.

> > T fun(T, alias f)(){
> >     T s;
> >     return s;
> > }
> > 
> > void main() {
> >     int x=2;
> >     void f(){}
> >     struct R { int f() { return x; } }
> >     auto m = fun!(R,f)();
> > }
> > 
> > (The reason why it works is that the alias function parameter forces local
> > template instantiation.)
> 
> In this case, as you say, func!(R, f) captures main's frame pointer (In other
> words, func!(R, f) will be instantiated as a _nested template_ in main).

I still think it might be sub-optimal that this has an influence on whether the
context pointer for R is available, but it is not a big deal.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list