Thread overview | |||||
---|---|---|---|---|---|
|
November 26, 2009 Class templates deriving from base class | ||||
---|---|---|---|---|
| ||||
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 |
November 26, 2009 Re: Class templates deriving from base class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael Mittner | 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?
>
> -Mike
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)
|
November 26, 2009 Re: Class templates deriving from base class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ary Borenszweig | 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 |
Copyright © 1999-2021 by the D Language Foundation