digitalmars.D - What's wrong with this template?
- BCS <BCS_member pathlink.com> Jan 06 2006
- Sean Kelly <sean f4.ca> Jan 06 2006
- BCS <BCS_member pathlink.com> Jan 06 2006
- Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> Jan 06 2006
- BCS <BCS_member pathlink.com> Jan 06 2006
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:Thanks!! Now, how about this: class T(int i) // line 1 { T!(i+1) inc()
Try .T!(i+1)
BINGO, that's just what I needed!
Jan 06 2006








BCS <BCS_member pathlink.com>