Getting the initial value of a class field in compile time.

realhet real_het at hotmail.com
Sat Feb 8 23:37:56 UTC 2020


Hello,

class A{
   int i = 42;
}

Is there a way to get that 42? (Input is the class A and the name 
of the field 'i')

A.i.init returns 0, so it doesn't care about the class.

classinfo.m_init can be an option, but maybe there's a nicer way 
to do this?

Thx!


More information about the Digitalmars-d-learn mailing list