auto ref function parameters in a free function

Martijn Pot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 3 12:22:14 PDT 2014


On Sunday, 3 August 2014 at 19:07:32 UTC, Vlad Levenfeld wrote:
> This doesn't work:
>
> bool less_than (T)(auto ref T a, auto ref T b)
> {
> 	return a < b;
> }
>
> Error: auto can only be used for template function parameters
>
> What am I doing wrong? Is this not a template function?

I think you can just skip 'auto'.

Have a look at http://dlang.org/function.html , especially the 
function parameters section.


More information about the Digitalmars-d-learn mailing list