Can I run this at compile time?

Marc jckj33 at gmail.com
Wed Dec 20 16:54:35 UTC 2017


Give this function I'd like to run it at compile time:

	import std.concurrency : Generator, yield;
>	Generator!string getNonIntegralMembers() {
>		return new Generator!string({
>			enum allMembers = __traits(derivedMembers, C);
>			foreach(enum string member; allMembers) {
>				bool isInteg = __traits(isIntegral, >__traits(getMember, C, 
>member));
>				if(!isInteg) {
>					yield(member);
>				}
>			}
>		});
>	}

but when I do:

> enum string[] members = getNonIntegralMembers();
> writeln(members);

I get the following erros:

C:\D\dmd2\windows\bin\..\..\src\druntime\import\core\thread.d(4059): Error: static variable PAGESIZE cannot be read at compile time
C:\D\dmd2\windows\bin\..\..\src\phobos\std\concurrency.d(1548):   
      called from here: super.this(dg, PAGESIZE * 4u, PAGESIZE)
app.d(96):        called from here: getNonIntegralMembers()



More information about the Digitalmars-d-learn mailing list