www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Classinfo of a base class.

reply =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
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
Nov 03 2004
parent reply "Walter" <newshound digitalmars.com> writes:
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
Nov 03 2004
parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
Walter schrieb am Donnerstag, 4. November 2004 05:04:
 super.classinfo.name should work.
code: test2 '_staticCtor' a.d(4): 'super' is only allowed in non-static member functions a.d(4): no property 'classinfo' for type 'int'
Nov 03 2004
next sibling parent larrycowan <larrycowan_member pathlink.com> writes:
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: test2 '_staticCtor' a.d(4): 'super' is only allowed in non-static member functions a.d(4): no property 'classinfo' for type 'int'
void display_name() { Internal error: e2ir.c 814
Nov 04 2004
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"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: 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.
Nov 04 2004