Value of type enum members

Andrey Zherikov andrey.zherikov at gmail.com
Tue Jan 19 20:27:30 UTC 2021


Could someone please explain why there is a difference in values 
between compile-time and run-time?


struct T
{
     int i;
     this(int a) {i=a;}
}

enum TENUM : T
{
     foo = T(2),
     bar = T(3),
}

void main()
{
     pragma(msg, TENUM.foo);    // T(2)
     pragma(msg, TENUM.bar);    // T(3)
     writeln(TENUM.foo);        // foo
     writeln(TENUM.bar);        // bar
}


More information about the Digitalmars-d-learn mailing list