Compile-Time Value Trait
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 23 15:27:40 PDT 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);
}
More information about the Digitalmars-d-learn
mailing list