"<Type> is not mutable" when using ref return type
Jonathan M Davis
jmdavisProg at gmx.com
Fri May 20 11:42:57 PDT 2011
> On Thu, 19 May 2011 00:22:42 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
>
> wrote:
> > On 2011-05-18 20:55, %u wrote:
> >> Hi!
> >>
> >> Is this a bug, or is it intentional that this fails? I can't come up
> >> with any case where it would cause a problem, but the compiler doesn't
> >>
> >> like the fact that there's a const in the structure:
> >> struct Temp { const int a; int b; }
> >>
> >> auto ref foo(Temp* t) { return *t; } //Error
> >
> > As soon as you do *t, you're copying the value.
>
> That's not true, if it's ref, it just copies the reference.
Well, I wasn't sure either way, and when I tested it by creating a postblit
which printed, it printed. So, either I ran into a bug (quite possible), or I
definitely misunderstood what was going on.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list