Function template argument deduction
Uknown
sireeshkodali1 at gmail.com
Sat Apr 7 06:26:24 UTC 2018
On Saturday, 7 April 2018 at 05:58:10 UTC, Paul Backus wrote:
> On Saturday, 7 April 2018 at 05:46:07 UTC, Uknown wrote:
>> I don't see the error you are talking about:
>> https://run.dlang.io/is/XWPIc1
>>
>> Are you using the latest compiler?
>
> Compile with -unittest.
>
> And yes; I'm using DMD 2.079.0.
Now I feel silly. Anyway, I played around with your code. One
thing I found was `cons.head` returns a `T`, which can't be
appended to a string. You can fix this with
`cons.head.to!string`, where `to` is from std.conv. I'm not sure
why IFTI isn't deducing `T` to be `int` though. Hopefully some
one else can help out here.
What I did notice though is that when
`string list2string(T)(List!T list)` was changed to
`string list2string(T)(VariantN!(16LU, Nil, Tuple!(T, "head",
This*, "tail")) list)`
The compiler correctly deduce `T` to be `int`
More information about the Digitalmars-d-learn
mailing list