digitalmars.D.learn - Compile-Time Value Trait
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/3) Aug 23 2014 I'm looking for a trait, say isCTExpression, that can check
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (4/5) Aug 23 2014 I just say
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (16/17) Aug 23 2014 As a complement I came up with
I'm looking for a trait, say isCTExpression, that can check whether an alias parameter is an expression evaluable during compile-time? Have anybody written such a thing?
Aug 23 2014
On Saturday, 23 August 2014 at 22:12:06 UTC, Nordlöw wrote:I'm looking for a trait, say isCTExpression, that can checkI just say http://forum.dlang.org/thread/mailman.1953.1373509028.13711.digitalmars-d puremagic.com Is this still the preferred way to do it?
Aug 23 2014
On Saturday, 23 August 2014 at 22:14:34 UTC, Nordlöw wrote:On Saturday, 23 August 2014 at 22:12:06 UTC, Nordlöw wrote:As a complement I came up with /** Check if the value of $(D expr) is known at compile-time. See also: http://forum.dlang.org/thread/owlwzvidwwpsrelpkbok forum.dlang.org */ enum isCTEable(alias id) = __traits(compiles, { enum idAlias = id; }); unittest { static assert(isCTEable!11); enum x = 11; static assert(isCTEable!x); auto y = 11; static assert(!isCTEable!y); }
Aug 23 2014