How can I tell if the give parameter can be run at compile time?

Jack jckj33 at gmail.com
Mon Mar 1 20:05:57 UTC 2021


bool g(T)(T)
{
  	return __traits(compiles, mixin("{ enum a = t; }"));
}


int a;
enum s = "";
// both return false but g(s) is expected to return true
pragma(msg, g(s));
pragma(msg, g(a));



More information about the Digitalmars-d-learn mailing list