Advanced const propagation for structs

Nicholas Wilson via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 16 06:17:09 PDT 2016


On Sunday, 16 October 2016 at 08:36:17 UTC, 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

Is there a way to say "the constness (and/or immutability) of 
this type is dependent on the type of a template parameter". i.e. 
signal that const A!B is interchangeable with A!(const B) and 
const A!(const B)?

If not does it make sense to add this?


More information about the Digitalmars-d mailing list