We need a typesystem-sanctioned way to cast qualifiers away

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 21 17:39:25 PDT 2015


On 6/20/15 12:30 AM, Daniel N wrote:
> On Saturday, 20 June 2015 at 00:07:12 UTC, Andrei Alexandrescu wrote:
>> Again, the reference to IAllocator must be unqualified even inside an
>> otherwise qualified object.
>>
> no love for a container factory?
>
> struct IAllocator{}
> struct container(T){}
>
> template factory(T)
> {
>    struct factory
>    {
>      T          contain; // potentially const
>      IAllocator mutable;
>
>      alias contain this;
>    }
> }
>
> auto c = factory!(const container!uint)();

The container must be self-contained (ehm), i.e. be able to destroy 
itself. Also, people may use by mistake one factory for creating one 
container and a different one for adding elements to it. -- Andrei



More information about the Digitalmars-d mailing list