Any word on the return-type const syntax?

Walter Bright newshound1 at digitalmars.com
Fri Dec 7 19:55:22 PST 2007


Janice Caron wrote:
> 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?

	TransferConst!(U,T) ptr(this U)() { return a.ptr; }



More information about the Digitalmars-d mailing list