On Wednesday, 26 December 2012 at 22:52:29 UTC, Jonathan M Davis wrote:
On Wednesday, December 26, 2012 23:02:25 deadalnix wrote:
Sound like the way to go for me. But is auto ref needed in such
case ? Why not simply allow ref to behave that way ?

Because there's a very large difference between a function intended to take arguments by ref and one where you don't care.

With auto ref, you're specifically saying that you don't care whether the function is given an lvalue or rvalue. You just want it to avoid unnecessary copies. That's very different. And auto ref then not only then protects you from cases of passing an rvalue to a function when it needs an lvalue, but it makes it clear in the function signature which is expected.

Not to bring back something that might be considered closed, But is auto ref going to be allowed for non-template functions in an upcoming version? There's plenty of times I'd like to use ref when possible but don't want to write a forwarding function converting non-ref to ref.

Reply via email to