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;
static assert(is(typeof(x) == typeof(y)));
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!(AddrSpace.Global, T);
dmd famously doesn't complain about attributes that do nothing,
as in this case.
-Steve
I kluged this into place in LDC
https://github.com/ldc-developers/ldc/pull/2509/commits/7cf6f417f95a5bffa4b18f2d8b132ca8f0e900d3#diff-33d7d08455db33f1182e3936fd2ba3f9R896