auto ref and non-templated functions
Peter Alexander
peter.alexander.au at gmail.com
Mon Dec 24 16:56:42 PST 2012
On Monday, 24 December 2012 at 17:40:54 UTC, Jonathan M Davis
wrote:
> Why can't we simply make auto ref work with non-templated
> functions by making
> it automatically generate both the ref and non-ref versions?
>
> [snip]
>
> What problems does this cause? Why haven't we just done this
> already?
What does this generate?
auto foo(auto ref S a, auto ref S b, auto ref S c, auto ref S d)
{ ... }
16 different functions, one for each combination? Sounds like a
bad idea.
> And if that doesn't work, can we simply make it so that the
> compiler
> automatically creates a variable when you pass an rvalue to a
> non-templated
> auto ref function?
I don't see any problems with this, but I admittedly haven't
thought too much about it.
More information about the Digitalmars-d
mailing list