SListRange assignable elements

bearophile bearophileHUGS at lycos.com
Tue Apr 20 18:31:52 PDT 2010


If you add this method (a little tested):

    /// ditto
    void front(T newvalue)
    {
        enforce(_root);
        _root._value = newvalue;
    }
    
to std.range.SListRange, then std.range.hasAssignableElements on it is true.
Is this a meaningful/useful change?


And isn't an assert enough and faster inside those SListRange methods? Linked list sometimes have to be fast, while adding execptions to all their methods might be less efficient.

So I think something like this can be enough (untested):

    /// ditto
    void front(T newvalue)
        in {
            assert(_root);
        body {
            _root._value = newvalue;
        }

Bye,
bearophile



More information about the Digitalmars-d mailing list