version(StdDoc)

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 24 17:43:35 UTC 2018


On Saturday, November 24, 2018 9:28:47 AM MST Stanislav Blinov via 
Digitalmars-d-learn wrote:
> On Saturday, 24 November 2018 at 07:00:31 UTC, Jonathan M Davis
>
> wrote:
> > [not legal]
> >
> > enum Foo
> > {
> >
> >     a,
> >     b,
> >     version(linux) c = 42,
> >     else version(Windows) c = 54,
> >
> > }
> >
> > You're forced to version the entire enum.
>
> Not in this case, no:
>
> enum Foo
> {
>      a,
>      b,
>      c = {
>         version(linux) return 42;
>         else version(Windows) return 54;
>      } ()
> }
>
> /pedantry

LOL. That's an interesting trick. It's ugly and hacky, but it does work
around the problem. I'm still inclined to think though that it should be
legal to just use version directly in the member list.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list