Request for a more powerful template specialization feature

data pulverizer via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 15 04:05:04 PDT 2017


On Saturday, 15 July 2017 at 10:34:13 UTC, Enamex wrote:
>
> But specializations are quite different from constraints, no? 
> Constraints wouldn't help when the template name is overloaded 
> and passes the constraint checks of several different template 
> implementations; specializations narrow things down for 
> overload resolution.
>
> Unless I'm misunderstanding the OP or everyone else in the 
> thread somehow :/

That's exactly right, you've probably put it better than I have! 
Specializations are quite different from constraints and I have 
found as you said that specializations are a great way to narrow 
things down for overload resolution. I use them to dispatch 
methods and they are the easiest way to specify a known set of 
kinds on a method set. When you narrow to your specialization set 
like that it will always work in the same way - no rouge types 
will mess things up.


More information about the Digitalmars-d mailing list