alias butAtLeast = max; 5.butAtLeast(6);

SimonN via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 12 04:43:36 PST 2015


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


More information about the Digitalmars-d-learn mailing list