[Issue 12133] Relaxed read-modify-write for shared lvalues
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 11 15:49:53 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12133
--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-02-11 15:49:51 PST ---
(In reply to comment #2)
> (In reply to comment #1)
>
> > shared int i;
> > ++cast()i;
>
> cast()i would cast away everything, including const, silently :)
Oops. Maybe something like:
-----
template Unshared(T)
{
static if (is(T U == shared inout const U)) alias Unshared = U;
else static if (is(T U == shared inout U)) alias Unshared = U;
else static if (is(T U == shared const U)) alias Unshared = U;
else static if (is(T U == shared U)) alias Unshared = U;
else alias Unshared = T;
}
ref unshared(T)(ref T var)
{
return *cast(Unshared!T*)&var;
}
void main()
{
shared int x;
++unshared(x);
assert(x == 1);
}
-----
Unshared code based off of Unqual.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list