On Tuesday, 9 April 2024 at 00:02:02 UTC, Richard (Rikki) Andrew
Cattermole wrote:
```d
enum Value = (a, b) {
return a + b;
}(1, 2);
```
This alone should be a CTFE only function.
But if we want template parameters, we'd need to wrap it with
the template.
```d
template Value(int a, int b) {
enum Value = () {
return a + b;
}();
}
int value = Value!(1, 2);
```
Does that help?
I had to reread this a few times to get a sense of what this is.
I might have just got it. This is effectively a CTFE function for
generating a constant based on the sum of two numbers, right?
Doing `int value = Value!(1, 2);` would set `value` to 3, right?
I suppose this was a good new thing to learn, though I'm still
quite far from being able to construct a function from another
function using a template.
I suppose that if I wanted it to make a function from another
function, I may be able to do it in a template using some `static
foreach` to make arrays of function parameters, and then combine
them together without the use of strings, instead using
placeholders (aliases or whatever they'd be called) and maybe the
`tupleof` function. Am I headed in the right direction (if you
can understand my weak attempt to describe the direction I'm
thinking of going in)?