Re: How to declare static compile-time assoc array inside struct?

2018-08-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 17, 2018 9:59:18 AM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/13/18 9:21 AM, Andrey wrote: > > On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: > >> You must use a module constructor to initialize it. > > > > Tried this: > > static this() >

Re: How to declare static compile-time assoc array inside struct?

2018-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/18 9:21 AM, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() `shared static this()` normal static this runs on every thread creation, and so cannot modify immutable data.

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:14:56 AM MDT Andrey via Digitalmars-d-learn wrote: > On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: > > Unsupported. AA's don't go between CT and RT. You must use a > > module constructor to initialize it. > > Will be supported in future? Maybe,

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Timoses via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...",

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Seb via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...",

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...", Test.Type.Three: "And... Three!"]; } struct Test { // ... } I

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: Unsupported. AA's don't go between CT and RT. You must use a module constructor to initialize it. Will be supported in future?

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/08/2018 11:38 PM, Andrey wrote: Hello, I need to declare a static compile-time assoc array inside struct:     struct Test     {     enum Type : ubyte     {     One,     Two,     Three     }     static immutable string[Type] DESCRIPTION =

How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
Hello, I need to declare a static compile-time assoc array inside struct: struct Test { enum Type : ubyte { One, Two, Three } static immutable string[Type] DESCRIPTION = [Type.One: "One!", Type.Two: "It's Two...",