auto ref function parameters in a free function
Vlad Levenfeld via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 3 14:19:20 PDT 2014
On Sunday, 3 August 2014 at 19:43:53 UTC, anonymous wrote:
> If this exact code errors for you, it ... uhh ... could be
> platform specific? Are you on Windows?
Debian, and your code works for me. I figured out the problem - I
made less_than to serve as a default sorting predicate, so in a
few places there is something like this:
void sort (R, T = ElementType!R, alias compare = less_than!T)(R
range, T item)
{...}
And since auto ref parameters need actual parameters to deduce
whether they should be ref or not, less_than!T isn't an
instantiated template - its still an alias, because it still must
choose between having ref and value parameters.
So, it looks like I can't use auto ref with less-than. Which is
fine, if I need to quickly compare large structures I will just
pass in a ref_less_than predicate or something.
More information about the Digitalmars-d-learn
mailing list