digitalmars.D - What's wrong with this template?
- BCS (21/21) Jan 06 2006 this code:
- Sean Kelly (13/27) Jan 06 2006 Try this:
- BCS (16/48) Jan 06 2006 Thanks!!
- Ivan Senji (2/10) Jan 06 2006 Try .T!(i+1)
- BCS (2/15) Jan 06 2006 BINGO, that's just what I needed!
this code: vvvvvvvv class T(int i) // line 1 { T!(i) dup() { return new T!(i); } } void main() { T!(1) t = new T!(1); } ^^^^^^^^ gives these errors: (3): template instance T is not a template declaration, it is a class (3): T!(1) is used as a type (5): template instance T is not a template declaration, it is a class (5): T!(1) is used as a type (11): T!(1) is used as a type What an I doing wrong?
Jan 06 2006
BCS wrote:this code: vvvvvvvv class T(int i) // line 1 { T!(i) dup() { return new T!(i); } } void main() { T!(1) t = new T!(1); }Try this: class T(int i) // line 1 { T dup() { return new T(); } } void main() { T!(1) t = new T!(1); }
Jan 06 2006
Thanks!! Now, how about this: class T(int i) // line 1 { T!(i+1) inc() { return new T!(i+1)(); } } void main() { T!(1) t = new T!(1); T!(2).T t2 = t.inc(); } can you use a template inside it's self? Sean Kelly wrote:BCS wrote:this code: vvvvvvvv class T(int i) // line 1 { T!(i) dup() { return new T!(i); } } void main() { T!(1) t = new T!(1); }Try this: class T(int i) // line 1 { T dup() { return new T(); } } void main() { T!(1) t = new T!(1); }
Jan 06 2006
BCS wrote:Thanks!! Now, how about this: class T(int i) // line 1 { T!(i+1) inc()Try .T!(i+1)
Jan 06 2006
Ivan Senji wrote:BCS wrote:BINGO, that's just what I needed!Thanks!! Now, how about this: class T(int i) // line 1 { T!(i+1) inc()Try .T!(i+1)
Jan 06 2006