Advanced const propagation for structs
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 16 05:18:47 PDT 2016
On 10/16/2016 11:36 AM, Ilya Yaroshenko wrote:
> Hi,
>
> Extern precompiled Mir GLAS requires additional API changes.
> Reduced example:
>
> ```d
> struct S(T)
> {
> size_t len;
> T ptr;
> }
>
> auto foo(S!(const(double)*) sl)
> {
> }
>
> S!(double*) a;
> const S!(double*) b;
>
> foo(a); // fails
> foo(b); // fails
>
> ```
>
> https://issues.dlang.org/show_bug.cgi?id=16616
This issue has been discussed before in context of custom containers and
AFAIK so far no one was able to come up with even theoretical concept of
how it can be possibly addressed. The issue is crazy complicated because
of how D templates work:
struct S (T)
{
static if (is(typeof(T) == const))
int a;
else
string a;
}
const S!(int) one;
S!(const int) two;
pragma(msg, typeof(one.a)); // string
pragma(msg, typeof(two.a)); // int
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20161016/f821cd15/attachment.sig>
More information about the Digitalmars-d
mailing list