auto ref and non-templated functions

Jens Mueller jens.k.mueller at gmx.de
Tue Dec 25 02:12:43 PST 2012


Jonathan M Davis wrote:
> 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.

I'm not sure but doesn't the compiler only create such a function when
it is called.
Still it may be confusing but it's similar to a function template. But
here it's a template regarding passing convention.

Jens


More information about the Digitalmars-d mailing list