<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 3, 2010, at 9:55 AM, Howard Hinnant wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Oct 3, 2010, at 12:53 PM, Douglas Gregor wrote:<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">On Oct 3, 2010, at 6:59 AM, Howard Hinnant wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Author: hhinnant<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Date: Sun Oct  3 08:59:56 2010<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">New Revision: 115461<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=115461&view=rev">http://llvm.org/viewvc/llvm-project?rev=115461&view=rev</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Log:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Tweak to make clang blocks work with std::functional (very fragile)<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Won't we need _Block_copy calls when putting a block into a std::function, _Block_dispose when destroying that std::function, etc?<br></blockquote><br><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.<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div></body></html>