<div dir="ltr">On 10 May 2013 05:39, Rob T <span dir="ltr"><<a href="mailto:alanb@ucora.com" target="_blank">alanb@ucora.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thursday, 9 May 2013 at 19:26:37 UTC, Jonathan M Davis wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Thursday, May 09, 2013 19:45:16 Peter Alexander wrote:<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It seems that 'auto ref' would be suitable, provided we can find<br>
a way for it to work with normal functions (in a sensible way,<br>
not like templates).<br>
</blockquote>
<br></div><div class="im">
That's trivial enough. All you have to do is lower code like<br>
<br>
auto foo(auto ref int i) {...}<br>
<br>
foo(5);<br>
<br>
to something like<br>
<br>
auto foo(ref int i) {...}<br>
<br>
auto __temp = 5;<br>
foo(__temp);<br>
<br>
And temporaries end up on the stack anyway, so you wouldn't really even have<br>
to lower it to quite like that, but that's what would be happening<br>
conceptually. It's also what would happen if plain ref accepted rvalues. It's<br>
just that we avoid certain classes of issues by having something distinct from<br>
plain ref for accepting rvalues by ref. The implementation itself is<br>
straightforward. If anything, I think that argument comes down primarily to<br>
two things:<br>
<br>
1. Should plain ref accept rvlaues?<br>
<br>
2. If plain ref shouldn't accept rvalues, then what attribute do we use to<br>
accept rvalues by ref?<br>
<br>
And given that the whole point of adding auto ref to the language was to solve<br>
exactly this problem, I think that it makes perfect sense to just use auto<br>
ref.<br>
<br>
- Jonathan M Davis<br>
</div></blockquote>
<br>
So, if I understand correctly, auto ref for templates will end up doing exactly the same thing as auto ref for non-template functions? That would be perfect, otherwise it'll be terribly confusing.<br>
</blockquote></div><br></div><div class="gmail_extra" style>I don't think this is entirely true, auto ref is a template concept, that is, "automatic ref-ness", it selects the ref-ness of the argument automatically, at compile time, just like auto applied everywhere else (selects a type for instance, at compile time). This concept doesn't make any sense applied to a non-template. It *IS* a ref as specified by the programmer, there's nothing 'automatic' about it.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>So to say it will do 'exactly the same thing' is a misunderstanding. I argue that 'auto ref' as applied to non-templates will only create confusion, it effectively re-enforcesĀ the type of confusion that you have just shown.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>This is the reasoning for the argument behind scope ref, which to my mind actually makes good sound sense, and should lead people to a proper understanding of what you are actually doing.</div>
<div class="gmail_extra" style>Considering the key argument against 'scope ref' is that people don't want to require more attributes to make use of it, I don't see how 'auto ref' satisfies this argument either.<br>
</div><div class="gmail_extra" style>Thus, I am quite happy happy with 'ref', it can be made safe, satisfies the argument above, and this seems like a very good start that we might actually all agree on.</div></div>