How can I tell if the give parameter can be run at compile time?
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 1 20:18:01 UTC 2021
On Mon, Mar 01, 2021 at 08:05:57PM +0000, Jack via Digitalmars-d-learn wrote:
> 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));
https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time
T
--
They pretend to pay us, and we pretend to work. -- Russian saying
More information about the Digitalmars-d-learn
mailing list