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.
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
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=
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.
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 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