Neater enum + version

Neia Neutuladh neia at ikeran.org
Sun Nov 18 17:52:21 UTC 2018


On Sun, 18 Nov 2018 17:47:07 +0000, Vladimirs Nordholm wrote:
> Is there anyway to make it "neater"? Maybe something in one line:
> 
>      enum foo = version (Posix) { "posix" } : { "other" } ;

If you're doing it often:

T ifPosix(T)(T a, T b)
{
  version (Posix) return a; else return b;
}
enum foo = ifPosix("posix", "other");

If it's a one-off thing, though, there's not much you can do.


More information about the Digitalmars-d-learn mailing list