July 15, 2017 Re: Request for a more powerful template specialization feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Enamex | 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.
|
July 17, 2017 Re: Request for a more powerful template specialization feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, 14 July 2017 at 19:49:05 UTC, Andrei Alexandrescu wrote: > > An effective way of improving the state of affairs would be to create a PR that makes the constraint easier to read and write, e.g.: > > among!(R, double, int) && among!(W, string, char, dchar) > > In fact it's surprising it hasn't been proposed yet. > > Andrei Forgive me, but what about anySatisfy https://dlang.org/library/std/meta/any_satisfy.html |
July 17, 2017 Re: Request for a more powerful template specialization feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to jmh530 | On Monday, 17 July 2017 at 12:29:41 UTC, jmh530 wrote:
>
> Forgive me, but what about anySatisfy
> https://dlang.org/library/std/meta/any_satisfy.html
Oh sorry, I see that's a little different.
|
Copyright © 1999-2021 by the D Language Foundation