Re: __gshared as part of alias

2018-01-18 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 22:56:09 UTC, kinke wrote: On Wednesday, 17 January 2018 at 22:01:57 UTC, Johan Engelen wrote: ``` struct GSharedVariable(AddrSpace as, T) { static __gshared T val; alias val this; } alias Global(T) = GSharedVariable!(AddrSpace.Global, T);

Re: __gshared as part of alias

2018-01-17 Thread kinke via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 22:01:57 UTC, Johan Engelen wrote: ``` struct GSharedVariable(AddrSpace as, T) { static __gshared T val; alias val this; } alias Global(T) = GSharedVariable!(AddrSpace.Global, T); Global!float bar1; // __gshared ``` Only 1 value per T though. ;)

Re: __gshared as part of alias

2018-01-17 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 12 January 2018 at 04:25:25 UTC, Nicholas Wilson wrote: Is there a way to make __gshared part of an alias? Hi Nick, how about this? ``` struct GSharedVariable(AddrSpace as, T) { static __gshared T val; alias val this; } alias Global(T) = GSharedVariable!(AddrSpace.Global

Re: __gshared as part of alias

2018-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 17, 2018 10:44:24 Nicholas Wilson via Digitalmars-d- learn wrote: > On Wednesday, 17 January 2018 at 07:53:24 UTC, Jonathan M Davis > > wrote: > > I don't know what you're doing, and maybe __gshared is the > > appropriate solution for what you're trying to do, but in > >

Re: __gshared as part of alias

2018-01-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 07:53:24 UTC, Jonathan M Davis wrote: I don't know what you're doing, and maybe __gshared is the appropriate solution for what you're trying to do, but in general, if you're not trying to bind to a C global variable, you should be using shared, and using

Re: __gshared as part of alias

2018-01-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 17, 2018 07:30:30 Nicholas Wilson via Digitalmars-d- learn wrote: > On Wednesday, 17 January 2018 at 02:37:07 UTC, Steven > > Schveighoffer wrote: > > On 1/11/18 11:25 PM, Nicholas Wilson wrote: > >> Is there a way to make __gshared part of an alia

Re: __gshared as part of alias

2018-01-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 02:37:07 UTC, Steven Schveighoffer wrote: On 1/11/18 11:25 PM, Nicholas Wilson wrote: Is there a way to make __gshared part of an alias? No, __gshared is a storage class, not a type constructor, so it has no meaning as part of a type: __gshared int x; int y

Re: __gshared as part of alias

2018-01-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/11/18 11:25 PM, Nicholas Wilson wrote: Is there a way to make __gshared part of an alias? No, __gshared is a storage class, not a type constructor, so it has no meaning as part of a type: __gshared int x; int y; static assert(is(typeof(x) == typeof(y))); as in enum AddrSpace : uint

__gshared as part of alias

2018-01-11 Thread Nicholas Wilson via Digitalmars-d-learn
Is there a way to make __gshared part of an alias? as in enum AddrSpace : uint { Private = 0, Global = 1, Shared = 2, Constant = 3, Generic = 4, } struct Variable(AddrSpace as, T) { T val; alias val this; } alias Global(T) = __gshared Variable