On Oct 3, 2010, at 9:55 AM, Howard Hinnant wrote:
> On Oct 3, 2010, at 12:53 PM, Douglas Gregor wrote:
>
>>
>> On Oct 3, 2010, at 6:59 AM, Howard Hinnant wrote:
>>
>>> Author: hhinnant
>>> Date: Sun Oct 3 08:59:56 2010
>>> New Revision: 115461
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=115461&view=rev
>>> Log:
>>> Tweak to make clang blocks work with std::functional (very fragile)
>>
>> Won't we need _Block_copy calls when putting a block into a std::function,
>> _Block_dispose when destroying that std::function, etc?
>
> <shrug> I don't know. If so then I would think it unsafe to instantiate any
> template with a block (not just std::function). Such behavior doesn't follow
> C++ generic syntax/semantics.
IIUC, it's actually a library policy issue. My understanding is that blocks
effectively capture by reference until you call _Block_copy, so when a library
function accepts a block parameter it either (1) agrees to call it immediately,
while the caller is still on that stack, or (2) _Block_copy the block to save a
copy of the block elsewhere and run it later.
Since std::function is mainly a mechanism for "save a copy of the function
object to call later", I think it makes sense to _Block_copy/_Block_dispose
automatically.
- Doug_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits