<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 2, 2017 at 4:09 PM Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> writes:<br>
<br>
> Oh, huh, yeah - right you are (I was rather hoping that "T&" would derive T<br>
> as "const U" when passed a temporary, but as you've pointed out, it<br>
> doesn't).<br>
><br>
> Yeah, I'd be in favor of what you've done then - passing T&& so temporaries<br>
> or locals can be passed by reference without undue copying in either case.<br>
<br>
Sorry, what copying?<br></blockquote><div><br>If "const T&" is used, then users can't pass mutable data - which seems like a reasonable thing users of a parallel API might want (I want to do a parellel mutation of data - like if I have a vector of vectors and want to reduce the subvectors in some way - replace them with a single-element vector containing the sum of the elements of the original vector)<br><br>If "T" is used, then they can mutate data, but would've had to copy it first, which probably defeats the point (since then the side effects get thrown away at the end)<br><br>But sure - if you want to restrict the use of the API to non-mutating cases for now, it's your/LLD's code. But it seems like a reasonable implementation to use T&& thus allowing mutation or non-mutation (same as a normal for loop, or std::for_each, etc) without waiting for the specific use case.<br><br>Up to you,<br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Since this is an algorithm and not an adapter, no copying is necessary,<br>
right? If that is the case I think it is probably better to use "const<br>
T&".<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div></div>