Re: Template Inheritance

2016-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 31 July 2016 at 03:04:27 UTC, Gorge Jingale wrote: I like to build structures using template mixins because one can pick and choose functionality at compile time, but still have a relationship between different types. It would be really nice if one could sort of test if a template

Re: Template Inheritance

2012-02-25 Thread Timon Gehr
On 02/22/2012 01:13 AM, BLM wrote: That last one looks a lot better than my solution. It's certainly a lot clearer. One problem I discovered with using templates was that I ended up needing virtual functions, which means that I had to convert the template functions to mixins and just instantia

Re: Template Inheritance

2012-02-21 Thread BLM
That last one looks a lot better than my solution. It's certainly a lot clearer. One problem I discovered with using templates was that I ended up needing virtual functions, which means that I had to convert the template functions to mixins and just instantiate them for each type (at least there

Re: Template Inheritance

2012-02-19 Thread Jonathan M Davis
On Sunday, February 19, 2012 12:34:07 Jacob Carlborg wrote: > > Template functions are non-virtual. You can't derive from them. If you > > want > > the derived classes to have the same functions, you must redefine them in > > the derived class. > > > > - Jonathan M Davis > > Yeah, but isn't that

Re: Template Inheritance

2012-02-19 Thread Jacob Carlborg
On 2012-02-19 02:07, Jonathan M Davis wrote: On Sunday, February 19, 2012 00:55:59 %u wrote: I've been working on porting an old D library to D2, and I'm running into a nasty issue with templates and inheritance. I've got a base class like this: class Reader { void get(T)(ref T[] buffer);

Re: Template Inheritance

2012-02-18 Thread Timon Gehr
On 02/19/2012 01:55 AM, %u wrote: I've been working on porting an old D library to D2, and I'm running into a nasty issue with templates and inheritance. I've got a base class like this: class Reader { void get(T)(ref T[] buffer); } and a subclass like this: class SubReader { void ge

Re: Template Inheritance

2012-02-18 Thread Timon Gehr
On 02/19/2012 02:23 AM, %u wrote: I think I got it! This seems to work: class Derived { //Pulls in all the template forms in the base class template get(args ...) { alias Base.get!args get; } //Create new versions of get() here. } This kills IFTI for the base clas

Re: Template Inheritance

2012-02-18 Thread Jonathan M Davis
On Sunday, February 19, 2012 01:23:13 %u wrote: > I think I got it! This seems to work: > > class Derived { > //Pulls in all the template forms in the base class > template get(args ...) { > alias Base.get!args get; > } > > //Create new versions of get() here. > } That se

Re: Template Inheritance

2012-02-18 Thread Jonathan M Davis
On Sunday, February 19, 2012 01:17:42 %u wrote: > Thanks! I guess I'll just have to live with redefining the functions, do > some sort of interface/mixin thing, or change the class interface. It makes > sense that template functions aren't virtual (how are you supposed to deal > with vtables?), but

Re: Template Inheritance

2012-02-18 Thread %u
I think I got it! This seems to work: class Derived { //Pulls in all the template forms in the base class template get(args ...) { alias Base.get!args get; } //Create new versions of get() here. }

Re: Template Inheritance

2012-02-18 Thread %u
Thanks! I guess I'll just have to live with redefining the functions, do some sort of interface/mixin thing, or change the class interface. It makes sense that template functions aren't virtual (how are you supposed to deal with vtables?), but I wish that at least an alias declaration could work.

Re: Template Inheritance

2012-02-18 Thread Jonathan M Davis
On Sunday, February 19, 2012 00:55:59 %u wrote: > I've been working on porting an old D library to D2, and I'm running into a > nasty issue with templates and inheritance. I've got a base class like this: > > class Reader { > void get(T)(ref T[] buffer); > } > > and a subclass like this: > >

Re: Template Inheritance

2012-02-18 Thread %u
Correction: redefining in the *subclass*. Silly me.

Re: Template Inheritance

2012-02-18 Thread %u
In the interim, I'm just redefining the template in the base class, but that's a really annoying hack to have to perform every single time I have to make a new form of the template.