On Friday, 10 May 2013 at 04:44:29 UTC, Jonathan M Davis wrote:
2. We could say UFCS has an implicit ref-at-callsite if
needed, and will
not compile for rvalues. If you think about it, 'this' is
implicitly ref,
and UFCS is calling like the first argument is the 'this'
reference.
That would make using UFCS with ranges generally illegal, as
most range-based
funtions do not have ref parameters, and you generally don't
want them to be
passed by ref.
Why ? Range behavior is undefined when passed by value.
On the other hand, if ref at the callsite is optional, then the
lack of ref at
the call site means absolutely nothing. You're still going to
have to look at
every single function signature to determine if it takes a ref
argument or
not, meaning that the lack of ref at the call site buys you
nothing at best
and harms you at worst, because it gives you a false sense of
security that
the argument is not being passed by ref. Programmers would have
to be 100%
consistent in using ref at the callsite to avoid that, and
that's obviously
not going to happen.
It make sense when you pass by ref to modify things. In this case
passing an rvalue don't make any sense. If you di it for
performance, then this is yet another instance of the compiler
rewriting things to improve performances.