Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 03, 2004 Classinfo of a base class. | ||||
---|---|---|---|---|
| ||||
I would want to use the classinfo property of the base class in the static constructor of a template class, but the closest I could get was passing the class as an alias parameter: class Test(alias BaseClass) { static this() { writefln(BaseClass.classinfo.name); } } class TestBase : Test!(TestBase) { } Is there any other way to print the name of the base class in the static constructor? Thanks |
November 04, 2004 Re: Classinfo of a base class. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | super.classinfo.name should work. "Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:cmbofh$10o6$1@digitaldaemon.com... > I would want to use the classinfo property of the base class in the static constructor of a template class, but the closest I could get was passing the class as an alias parameter: > > class Test(alias BaseClass) > { > static this() > { > writefln(BaseClass.classinfo.name); > } > } > > class TestBase : Test!(TestBase) > { > } > > Is there any other way to print the name of the base class in the static constructor? > > Thanks |
November 04, 2004 Re: Classinfo of a base class. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter schrieb am Donnerstag, 4. November 2004 05:04: > > super.classinfo.name should work. > code: # import std.stdio; # class Foo : Object{ # static this(){ # writef(super.classinfo.name,"\n"); # } #} test2 '_staticCtor' a.d(4): 'super' is only allowed in non-static member functions a.d(4): no property 'classinfo' for type 'int' |
November 04, 2004 Re: Classinfo of a base class. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | In article <cmchq7$2khf$1@digitaldaemon.com>, Thomas Kuehne says... > >Walter schrieb am Donnerstag, 4. November 2004 05:04: >> >> super.classinfo.name should work. >> >code: ># import std.stdio; ># class Foo : Object{ ># static this(){ ># writef(super.classinfo.name,"\n"); ># } >#} > >test2 '_staticCtor' >a.d(4): 'super' is only allowed in non-static member functions >a.d(4): no property 'classinfo' for type 'int' > # import std.stdio; # class Foo : Object{ # static this(){ Foo.display_name(); } void display_name() { # writef(super.classinfo.name,"\n"); # } #} Internal error: e2ir.c 814 |
November 04, 2004 Re: Classinfo of a base class. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | "Thomas Kuehne" <thomas-dloop@kuehne.cn> wrote in message news:cmchq7$2khf$1@digitaldaemon.com... > Walter schrieb am Donnerstag, 4. November 2004 05:04: > > > > super.classinfo.name should work. > > > code: > # import std.stdio; > # class Foo : Object{ > # static this(){ > # writef(super.classinfo.name,"\n"); > # } > #} > > test2 '_staticCtor' > a.d(4): 'super' is only allowed in non-static member functions > a.d(4): no property 'classinfo' for type 'int' Ok, that's right. But try classinfo.base.name. |
Copyright © 1999-2021 by the D Language Foundation