tail const

Simen kjaeraas simen.kjaras at gmail.com
Sun Dec 26 03:04:28 PST 2010


Simen kjaeraas <simen.kjaras at gmail.com> wrote:

> Simen kjaeraas <simen.kjaras at gmail.com> wrote:
>
>> I've also considered a template on the form
>>
>>      mixin tailConst!( SimpleRange, SimpleRange!( Tail!T ) );
>> or
>>      mixin tailConst!( SimpleRange, Tail!T );
>
> A closer look at this reveals that it won't work that simply, because
> SimpleRange in this context is the struct, not the template. This,
> however, works:
>
>      mixin tailConst!( .SimpleRange, TailT! );
>
> Not sure how I like this.

After more problems, I have also come to the conclusion that what is
most commonly needed is not really tail-const, but head-mutable. Why
this took me more than a few minutes to consider, I do not know.

Common use-cases would then look like this:

struct MyRange( Range ) {
     HeadMutable!Range r;
     // Range primitives, TailConst support, etc.
}

-- 
Simen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailconst.d
Type: application/octet-stream
Size: 10864 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101226/e652590c/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailconst2.d
Type: application/octet-stream
Size: 1204 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101226/e652590c/attachment-0003.obj>


More information about the Digitalmars-d mailing list