April 24, 2004 template self-instantiation | ||||
---|---|---|---|---|
| ||||
Help: What am I doing wrong? ---------------------- struct test(T) { test!(T) func() { test!(T) res; return res; }; }; int main() { test!(int) a; a = a.func(); return 0; }; ---------------------- The gdc tells me "template instance test!(int) test is not a template declaration" |
April 24, 2004 Re: template self-instantiation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Norbert Nemec | "Norbert Nemec" <Norbert.Nemec@gmx.de> wrote in message news:c6dlsg$235$1@digitaldaemon.com... > Help: What am I doing wrong? > > ---------------------- > struct test(T) { > test!(T) func() { > test!(T) res; > return res; > }; > }; I think that everyone has this problem at first (I did) The solution is very simple: struct test(T) { .test!(T) func() { .test!(T) res; return res; } } The solution is . (gives acces to outer scope) and you don't need ; after struct and function declaration. > int main() { > test!(int) a; > a = a.func(); > return 0; > }; > ---------------------- > > The gdc tells me > "template instance test!(int) test is not a template declaration" > > |
Copyright © 1999-2021 by the D Language Foundation