Any word on the return-type const syntax?
Janice Caron
caron800 at googlemail.com
Sun Dec 9 08:25:20 PST 2007
On 12/9/07, Walter Bright <newshound1 at digitalmars.com> wrote:
> Janice Caron wrote:
> > But I think there's still a problem. If I write
> >
> > class MyArray(T)
> > {
> > T[] a;
> > TransferConst!(U,T*) ptr(this U)()
> > {
> > return a.ptr;
> > }
> > }
> >
> > const MyArray!(int) aa;
> > auto p = aa.ptr;
> >
> > Then presumably it won't compile, becase aa is not mutable,
>
> Template member functions are not instantiated until they are called.
I'm calling it! I'm calling it! See that line that says "auto p =
aa.ptr"? That (attempts to) call MyArray!(int).ptr(). However - as I
said - presumably it won't compile because aa is const, and the
function ptr(this U)() has not been declared as const. So there's a
problem. How may this problem be fixed?
More information about the Digitalmars-d
mailing list