[Issue 8850] Nested struct creation by a template
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 7 04:55:56 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8850
--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> 2012-11-07 04:55:54 PST ---
(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.
> 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).
--
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