Version block "conditions" with logical operators
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 10 09:06:47 PDT 2016
On 5/10/16 2:48 PM, Tomer Filiba wrote:
> On Tuesday, 10 May 2016 at 11:12:58 UTC, Tomer Filiba wrote:
>> Alternatively, an isVersion(x) predicate that I could use in a static
>> if could do the trick
>
> Well, I've come up with
>
> template isVersion(string ver) {
> mixin(format(q{
> version(%s) {
> enum isVersion = true;
> }
> else {
> enum isVersion = false;
> }
> }, ver));
> }
>
> pragma(msg, isVersion!"foo"); // false
> pragma(msg, isVersion!"assert"); // true
>
> But it feels hackish too
Not if we put it in the standard library :o). -- Andrei
More information about the Digitalmars-d
mailing list