<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 2, 2011, at 2:31 PM, Douglas Gregor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Nov 2, 2011, at 12:48 PM, John McCall wrote:<br><blockquote type="cite"><blockquote type="cite"><font class="Apple-style-span" color="#305ac5"><br></font></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">What do you propose? Capture the reference, even though it's almost surely going to refer to a temporary?<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Yes.  References are references.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Among the things that are wrong with doing a copy:<br></blockquote><blockquote type="cite">(1) It's inconsistent with the capture of l-value references.<br></blockquote><blockquote type="cite">(2) In my experience, l-value references are about equally likely<br></blockquote><blockquote type="cite"> to point into something stored on or owned by the stack, so it's<br></blockquote><blockquote type="cite"> not like those are really any safer.<br></blockquote><blockquote type="cite">(3) C++ programmers using blocks are certain to deal with both<br></blockquote><blockquote type="cite"> reference types and therefore to be surprised by the inconsistency.<br></blockquote><blockquote type="cite">(4) It has to be a copy, not a move, even though it's an r-value<br></blockquote><blockquote type="cite"> reference and the programmer presumably actually cares.<br></blockquote><blockquote type="cite">(5) Capturing a reference to a temporary or local is not actually<br></blockquote><blockquote type="cite"> dangerous except in situations where the block is copied to the<br></blockquote><blockquote type="cite"> heap, but there are plenty of APIs that don't need to do this.<br></blockquote><blockquote type="cite">(6) Unlike lambdas, there's no way to override this behavior, so<br></blockquote><blockquote type="cite"> this is actually a pretty strong expressivity constraint, and the<br></blockquote><blockquote type="cite"> workarounds either involve extra moves or terrible things like<br></blockquote><blockquote type="cite"> capturing a pointer to the temporary.<br></blockquote><br><br>Okay, I agree. Let's go with capturing these as references. Thanks, John.<br></div></blockquote><div><br></div>This was how it was treated before I made the change. We captured the reference, but could not write to </div><div>the referenced object in the block. Will back out the change.</div><div><br></div><div>- Fariborz</div><div><br><blockquote type="cite"><div><br><span class="Apple-tab-span" style="white-space:pre">  </span>- Doug</div></blockquote></div><br></body></html>