: in template specialization vs constraint

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 22 10:54:59 PST 2015


On 12/22/15 10:40 AM, Adam D. Ruppe wrote:

> In specialization, it will implicitly convert, it will just select the
> best match available.
>
> Make #1:
>
>      void func(T : ubyte)(T v) { writeln(1); }
>
> It will then use that for for the second line because it is a *better*
> match than :int, but :int still is a match so it works as a fallback.
>

Type specialization has some weird properties in this regard. Sometimes 
it needs to be exact or explicit, sometimes it doesn't.

http://forum.dlang.org/post/rvflnpxwzetpcphwxrgx@forum.dlang.org

-Steve


More information about the Digitalmars-d-learn mailing list