digitalmars.D.learn - Class templates deriving from base class
- Michael Mittner (21/21) Nov 26 2009 Hi!
- Ary Borenszweig (7/35) Nov 26 2009 Hi Mike,
- Michael Mittner (10/17) Nov 26 2009 Further investigation indicates that I have stumbled upon this bug:
Hi! I'm trying to do something like this (in D1): class Foo { // ... } class Bar(T) : Foo { // ... } alias Bar!(int) IntBar; alias Bar!(Mars) MarsBar; void main() { Foo x = new MarsBar(); } Common base class, one derived template class and a bunch of aliases that are then actually used in the code. But it seems like deriving a template class from a non-template one doesn't work. Is this supposed to work, am I doing something wrong or am I out of luck here? -Mike
Nov 26 2009
Michael Mittner wrote:Hi! I'm trying to do something like this (in D1): class Foo { // ... } class Bar(T) : Foo { // ... } alias Bar!(int) IntBar; alias Bar!(Mars) MarsBar; void main() { Foo x = new MarsBar(); } Common base class, one derived template class and a bunch of aliases that are then actually used in the code. But it seems like deriving a template class from a non-template one doesn't work. Is this supposed to work, am I doing something wrong or am I out of luck here? -MikeHi Mike, Why do you mean with "doesn't work"? If I define class Mars {} and compile your program it gives no error. Can you show the error the compiler is giving you? (you normally past the compiler output if a program doesn't compile so that others can help you faster... but in case it compiles, weird :-P)
Nov 26 2009
Ary Borenszweig wrote:Hi Mike, Why do you mean with "doesn't work"? If I define class Mars {} and compile your program it gives no error. Can you show the error the compiler is giving you? (you normally past the compiler output if a program doesn't compile so that others can help you faster... but in case it compiles, weird :-P)Further investigation indicates that I have stumbled upon this bug: http://d.puremagic.com/issues/show_bug.cgi?id=1538 Which seems to have been fixed in 1.047 or so, but I'm using 1.041 (the one that came with Tango) and I'm too lazy to update now (actually I'm not, but I fear this will be half an eternity of trial-and-error to get that build environment updated on both Linux and Windows - I'll rather wait for the next bundle from the Tango devs). Thanks for confirming that it should actually work! -Mike
Nov 26 2009