Any word on the return-type const syntax?

Janice Caron caron800 at googlemail.com
Fri Dec 7 14:21:58 PST 2007


On 12/7/07, Jason House <jason.james.house at gmail.com> wrote:
> > That can now be done with a template.
>
> Does that mean the return keyword affecting an input parameter won't ever be implemented?  IMHO, the return keyword is more elegant than using templates.

Maybe I'm being a bit dumb here, but I just don't seem to be able to
figure out how templates will help.

Here's a typical problem.

    class MyArray(T)
    {
        T[] a;

        T* ptr() { return a.ptr; }
        const(T)* ptr() const { return a.ptr; }
        invariant(T)* ptr() invariant { return a.ptr; }
    }

A template helps how, exactly?



More information about the Digitalmars-d mailing list