Any word on the return-type const syntax?
Janice Caron
caron800 at googlemail.com
Sun Dec 9 00:19:12 PST 2007
On 12/9/07, Stewart Gordon <smjg_1998 at yahoo.com> 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; }
> >>> }
>
> This doesn't work for me. Add any one (or more) of
>
> MyArray!(int) a;
> const(MyArray!(int)) c;
> invariant(MyArray!(int)) i;
>
> and I get (DMD 2.008)
>
> transfer_const.d(7): Error: cannot implicitly convert expression
> (cast(int*)(this.a)) of type int* to invariant(int)*
Yep, sorry. It should be
class MyArray(T:T)
Walter changed the syntax between D2.007 and D2.008. Constancy of
template parameters is now thrown away unless you do T:T.
More information about the Digitalmars-d
mailing list