How about "auto" parameters?

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Jun 7 18:33:52 PDT 2011


On 6/7/11, foobar <foo at bar.com> wrote:
> foo(a, b) { return a + b; } // will be lowered to:
> T foo(T) (T a, T b) { return a + b; }

Thanks to someone who was trying to be clever, the win32 bindings have
these templates:

template max(T) {
    T max(T a, T b)
    {
        return a > b ? a : b;
    }
}

template min(T) {
    T min(T a, T b)
    {
        return a < b ? a : b;
    }
}

They clash with std.algorithm : min and max, but at the same time they
can't really be instantiated in the same way. Now I have the situation
where they conflict but at the same time only the std.algorithm
templates can be instantiated. Compiler errors everywhere, great.

So now I have to force my code to use std.algorithm by importing via:
import std.algorithm : min, max;

or alternatively:
import std.algorithm;
alias std.algorithm.min min;
alias std.algorithm.max max;

Pain in the ass.


More information about the Digitalmars-d mailing list