[D1] type of type

%u e at ee.com
Wed Dec 29 08:56:41 PST 2010


== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> On Wed, 29 Dec 2010 10:33:21 -0500, %u <e at ee.com> wrote:
> > == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> >> On Thu, 23 Dec 2010 17:28:49 -0500, %u <e at ee.com> wrote:
> >> > Should have been this:
> >> >
> >> > void func(type t){
> >> >   new t();
> >> > }
> >> void func(T)(){
> >>     new T();
> >> }
> >> When you are passing types into functions, use templates.
> >> -Steve
> >
> > The reason I asked for a non-templated solution is because they don't
> > have a
> > common interface signature.
> I don't know what you mean.  Templated solution does not require a common
> interface.  This works with any type:
> void func(T)(){
>     T t;
> }
> Maybe you can post an example of what you are trying to solve?
> -Steve

Yeah, sorry, I meant it the other way around: I need a common interface.

class C1: I
..
class C9: I

I'd like to pass any C(a) type to any C(b) object such that C(b) can spawn a C(a).
What would be the common signature of these two functions?
And how would the object save the type?


More information about the Digitalmars-d-learn mailing list