[cfe-dev] libcxx: std::function should be able to capture blocks

Jared Grubb jared.grubb at gmail.com
Wed Oct 1 11:38:12 PDT 2014


== Background:
std::function will wrap anything that is callable (and can be copied/moved). Blocks are copyable and callable, however you need to use the reference counting Block_copy/Block_release functions.

== Request for Comment on the Patch:
I am working on a patch that will allow std::function to capture blocks correctly (under the right feature guards). 

Functionally, the patch is complete. However, it's not checkin-ready as I had a couple questions on the approach: 
 * Is the approach right? I specialized the __func storage class, as that seems to be the right thing to customize.
 * I have included some unit test implementations. There are quite a few std::function unit tests, so I wanted to make sure I was on the right track before I do all of them. 
 * Should I add tests for ObjC++ code, under ARC and non-ARC scenarios? There are no ObjC++ files in libcxx, and the test-runner does not yet support them. Adding this is not hard, but it's a change in how things are today.

If this looks like it's on the right track, I will flush out the rest of the unit tests, and optionally add ObjC++ unit tests.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-libcxx-function-with-blocks
Type: application/octet-stream
Size: 11976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141001/7ccae737/attachment.obj>
-------------- next part --------------


Jared



More information about the cfe-dev mailing list