On Fri, 20 May 2011 14:42:57 -0400, Jonathan M Davis <jmdavisp...@gmx.com> wrote:

On Thu, 19 May 2011 00:22:42 -0400, Jonathan M Davis <jmdavisp...@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.

It depends on the example, if you are assigning the result to another variable, that is where the copy may occur.

But if you do something like just take the address of the return, or pass it to something else that accepts ref, it should not call the postblit.

Most certainly it's not within the function.

-Steve

Reply via email to