Hello,

In the following code:

struct pair(T, U) {
        T first;
        U second;

        this(T arg_first, U arg_second) {
                first = arg_first;
                second = arg_second;
        }
};

void main() {

        pair!(char, uint) p1 = pair('a', 1);

}

I am getting the following error:

scratch.d(14): Error: struct scratch.pair cannot deduce function from argument types !()(char, int), candidates are:
scratch.d(2):        scratch.pair(T, U)
Failed: ["/usr/bin/dmd", "-v", "-o-", "scratch.d", "-I."]

Changing the offending line to:

pair!(char, uint) p1 = pair!(char, uint)('a', 1);

fixes the issue.

However I am interested to know why the first code couldn't deduce the types-- and why does it even have to try to deduce them, when I explicitly stated that p1 was of the type "pair of char and uint"?

Thanks,
L. Aleksic

Reply via email to