On 12.05.2012 14:39, Manu wrote:
On 12 May 2012 13:13, Jonathan M Davis <jmdavisp...@gmx.com
<mailto:jmdavisp...@gmx.com>> wrote:

    So, basically it's just the issue with neither ref nor const ref taking
    lvalues.


And the local references, and the bug.

    If you duplicate the functions (or use auto ref if they're templated
    functions), then it's not an issue.


Yes it is. Passing by value is NOT passing by reference, it's a totally
different operation. And what about non-const ref?
'in ref' would be very nice if it worked. It would basically replace
'const ref'.

    It sucks to have to duplicate stuff, but
    ref works just fine as long as you don't assume that it's going to
    allow you to
    pass rvalues to it.


Well there's the bugs we've seen in optimised codegen.
Duplicating with non-ref is not a solution. It's not even a workaround.
The only workaround is to receive a pointer, which ruins all those cases
in terms of syntax anyway.

    Personally, I almost always just have functions take
    structs by value, so it's a non-issue except for stuff like
    opEquals, which
    requires const ref (for at least one overload anyway).


Well I think it's safe to say most people pass data structs by
reference. If I saw someone pass a struct by val, I'd consider it a
bug/typo and fix it.

Brr... most ranges are structs. And yes, they are passed by value (rightfully so).


--
Dmitry Olshansky

Reply via email to