'Auto can only be used for template function arguments' what?

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 26 20:53:48 PDT 2012


On Wednesday, June 27, 2012 02:54:49 Mehrdad wrote:
> On Tuesday, 26 June 2012 at 16:37:30 UTC, Timon Gehr wrote:
> > On 06/26/2012 06:17 PM, Mehrdad wrote:
> >> void test1(T)(auto ref T) { }
> >> void test2() { int a = 5; test1!(int)(a); }
> >> 
> >> Is there any reason this should fail?
> > 
> > There is not. I suppose the compiler completes instantiation
> > without
> > looking at the function parameter.
> 
> Well the problem manifests itself in different ways, but would it
> be safe to say that
> 
> 	void foo(auto ref int) { }
> 
> should not cause problems either?

That isn't legal. auto ref can only be used with templated functions.

- Jonathan M Davis


More information about the Digitalmars-d mailing list