On 6/14/16 6:05 AM, pineapple wrote:
On Monday, 13 June 2016 at 22:54:13 UTC, Ali Çehreli wrote:
Tree!T tree(TL, T, TR)(TL left, T node, TR right) {
return new Tree!T(left, node, right);
}
There's also this:
Tree!T tree(TL, T, TR)(TL left, T node, TR right) if(
(is(TL == Tree!T) || is(TL == typeof(null))) &&
(is(TR == Tree!T) || is(TR == typeof(null)))
Alternative: if(is(typeof({Tree!T x = TL.init; x = TR.init; })))
This may seem similar, but actually can accept things that convert to
Tree!T as well.
The issue with the OP code is that the compiler is trying to match T
with the two null parameters, and can't work out the deduction.
-Steve