[cfe-commits] r143399 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGExpr.cpp test/CodeGenCXX/block-rvalue-reference-capture.cpp

Douglas Gregor dgregor at apple.com
Wed Nov 2 10:59:36 PDT 2011


On Nov 2, 2011, at 10:57 AM, jahanian wrote:

> 
> On Nov 2, 2011, at 10:19 AM, Douglas Gregor wrote:
> 
>> 
>> 
>>> Alternatively, we could just forbid the capturing of rvalue references. 
>>> Let the user make an explicit choice by either creating a local copy or 
>>> a local lvalue reference.
>> 
>> 
>> This might just be the best solution, since the only seems that is clear is that there are no clear semantics :)
>> 
>> Forcing users to perform the capture makes them choose between, e.g.,
>> 
>> 	__block T captured_x = move(x);
> 
> Yes.
> 
>> 
>> or
>> 
>> 	__block T &captured_x = x;
> 
> Wouldn't you be passing down reference to the temporary to the block here? Or, does semantic of rvalue-reference requires a copy
> being made here?


Yes, this would be passing down a reference to the temporary. That may be what you want, if you know your block is only going to die before you leave the current stack frame.

	- Doug



More information about the cfe-commits mailing list