On Friday, 14 February 2020 at 06:41:02 UTC, cc wrote:

import std.meta;

enum A = AliasSeq!(1, 2, 3, 4);

static foreach (idx, field; A) {
    static if (__traits(compiles, THREELOOP)) {} else {
        static if (field == 3) {
                pragma(msg, "Got a 3!");
                enum THREELOOP = 1; // works with enum, alias etc...
        }
        static if (idx == A.length - 1) {
                static assert(0, "Got no 3...");
        }
    }
}


https://run.dlang.io/is/BDmIml

Reply via email to