Re: Is there a way to get a template’s parameters and constraints?

2023-01-22 Thread Adam Ross Walker via Digitalmars-d-learn
On Friday, 20 January 2023 at 17:15:31 UTC, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? Apologies, I missed the key part of your question. But I think the above can be adapted if you were so inclined.

Re: Is there a way to get a template’s parameters and constraints?

2023-01-22 Thread Adam Ross Walker via Digitalmars-d-learn
There is a way but it's horrible. You can take the `.stringof` and parse the result. I knocked this up for something but it's not well tested and there are probably templates that it handles incorrectly. I'm not claiming this is any good, I just happened to have it. ```d enum

Re: Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 20 January 2023 at 17:15:31 UTC, Quirin Schroll wrote: For what I want, `constraintsOf` may expect every template parameter to be a type and to have a constraint. If I'm not mistaken, the following will help: https://dlang.org/phobos/std_range_primitives.html SDB@79=

Re: Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 20 January 2023 at 17:15:31 UTC, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? No, reflection over templates is very limited.

Re: Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/20/23 12:15 PM, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? Example: ```D void f(T1 : long, T2 : const(char)[])(T x) { } template constraintsOf(alias templ) { /*Magic here*/ } alias constraints = constraintsOf!f; //

Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Quirin Schroll via Digitalmars-d-learn
Is there a trait (or a combination of traits) that gives me the constraints of a template? Example: ```D void f(T1 : long, T2 : const(char)[])(T x) { } template constraintsOf(alias templ) { /*Magic here*/ } alias constraints = constraintsOf!f; // tuple(long, const(char)[]) ``` At the moment, I