auto ref and non-templated functions
Jonathan M Davis
jmdavisProg at gmx.com
Tue Dec 25 01:52:56 PST 2012
On Tuesday, December 25, 2012 01:56:42 Peter Alexander wrote:
> 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.
Excellent point.
> > 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.
I hope that it's feasible (or something close to it anyway) so that we can
actually solve this problem once and for all.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list