alias butAtLeast = max; 5.butAtLeast(6);
JR via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Dec 12 05:23:06 PST 2015
On Saturday, 12 December 2015 at 12:43:36 UTC, SimonN wrote:
> DMD v2.069.2-b1 on Linux.
>
> import std.algorithm;
>
> int a = max(5, 6); // works, a == 6
> int b = max!(int, int)(5, 6); // works, manual instantiation
> int c = 5.max(6); // works, UFCS call
>
> I would like to use the last syntax, but with an alias.
>
> alias butAtLeast = max; // works
> int d = butAtLeast(5, 6); // works
> int e = 5.butAtLeast(6); // error: no property
> 'butAtLeast' for type 'int'
>
> Aliasing the instantiated function 'max!(int, int)' instead of
> aliasing 'max' doesn't help: The 'int e' line will fail with
> the exact same error.
>
> Can I get the alias to work somehow in an UFCS chain?
>
> -- Simon
By putting it in the top level. I believe this is intentional but
I don't remember the reasoning.
More information about the Digitalmars-d-learn
mailing list