<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>If I understand correctly (and I very well might not), the idea is that auto ref is *always* ref, so only one function is generated. The main difference between auto ref and ref is that ref doesn't allow rvalues. Saying auto ref is basically like saying to the compiler: "yeah, I know it's an rvalue, still pass it as ref".<br></span></div><div><br></div><div>If that's correct, I think the way to look at it is these three situations:</div><div><br></div><div>1. I want to change the value, and/or I want to disallow rvalues: use ref</div><div>2. I want to pass by reference because the struct is large: use auto ref (includes rvalues), possibly const as well.<br></div><div>3. I want to optimize passing large structs for both rvalues and lvalues: use two overloads, one with const ref, one by
value.</div><div><br><span></span></div><div><span>Andrei, I hate to ask this, because I feel very confused from all the statements you have previously made, but could you explain this again?</span></div><div><br><span></span></div><div><span>To be honest, if what I've said is correct, it still sounds so clunky and awkward...</span></div><div><br><span></span></div><div><span>-Steve<br></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Walter Bright <walter@digitalmars.com><br> <b><span style="font-weight: bold;">To:</span></b> Discuss the dmd beta releases for D <dmd-beta@puremagic.com>
<br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, April 9, 2012 11:55 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [dmd-beta] D 2.059 beta 4<br> </font> </div> <br>
<br><br>On 4/9/2012 7:44 PM, Jonathan M Davis wrote:<br>> On Monday, April 09, 2012 19:40:43 Walter Bright wrote:<br>>> On 4/9/2012 7:32 PM, Nick Sabalausky wrote:<br>>>> Although, if there really is good merit to struct lits not veing lvalues,<br>>>> then maybe all we need is to wait until "auto ref" is usable for<br>>>> non-templates? (If that would even be possible...?)<br>>> Not possible, as the binary ABI would be different.<br>> It was my understanding that the auto ref was supposed to work with non-<br>> templated functions - at least what Andrei proposed was - but that you<br>> misunderstood that and made it only work with templates. And as long as it<br>> only works with templates, it's usefulness is very limited. opEquals would be<br>> a _prime_ case for where it would be useful.<br>><br><br>How could that possibly work for the same function, considering that the code <br>for each
would be quite different, including the calling code?<br><br>_______________________________________________<br>dmd-beta mailing list<br><a ymailto="mailto:dmd-beta@puremagic.com" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a><br>http://lists.puremagic.com/mailman/listinfo/dmd-beta<br><br><br> </div> </div> </blockquote></div> </div></body></html>