Template function specialization doesn't work

IGotD- nise at nise.com
Tue Jul 7 20:14:19 UTC 2020


On Tuesday, 7 July 2020 at 20:05:37 UTC, Steven Schveighoffer 
wrote:
> On 7/7/20 4:04 PM, Steven Schveighoffer wrote:
>
>> Have you tried (T: U[], U)(ref T[] s) ?
>
> Ugh... (T: U[], U)(ref T s)
>
> -Steve

Thank you, that worked and now it picked the correct overloaded 
function. I don't understand why and it is a bit counter 
intuitive. Why two template arguments as I'm not even us using U?

If you look at the article

https://dlang.org/articles/templates-revisited.html#specialization

Then it mentioned that (T : T*) would work. Intuitively, then you 
would think (T : T[]) would work.


More information about the Digitalmars-d-learn mailing list