Advanced const propagation for structs

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 16 10:01:54 PDT 2016


On Sunday, 16 October 2016 at 13:17:09 UTC, Nicholas Wilson wrote:
> 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?

A workaround was found https://github.com/dlang/phobos/pull/4869


More information about the Digitalmars-d mailing list