The Status of Const

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 16 07:12:08 PDT 2010


On Mon, 16 Aug 2010 09:11:20 -0400, dsimcha <dsimcha at yahoo.com> wrote:

> == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
>> There are other reasons to have tail-const other than classes.  For
>> example, there's no equivalent custom-range idiom for const(T)[].  You
>> simply can't make a custom range tail-const.
>> I admit I haven't used Rebindable much, but last I checked it was  
>> severely
>> out of date.
>> -Steve
>
> Rebindable's gotten a significant facelift lately.  Admittedly there are  
> still
> bugs but these are bugs in alias this/opDot, not in rebindable itself.

How do you tail-const a range?

struct Node(V)
{
    V v;
    Node * next;
}

struct Range(V)
{
    Node!V *n;

    void popFront() {n = n.next};
}

How does one implement popFront so it works on:

Rebindable!(const(Range!V)) r;

???

Rebindable is specifically for class references, it does nothing for  
ranges.

-Steve


More information about the Digitalmars-d mailing list