Eponymous template with static if
Michael Galuza
riddlermichael at gmail.com
Wed Aug 9 16:55:04 UTC 2023
It's well known that template functions in D are just kind of
eponymous template:
```d
T square(T)(T t) {
return t * t;
}
```
is lowered to
```d
template square(T) {
T square(T t) {
return t * t;
}
}
```
But if we write this:
```d
template square(T) {
static if (true) {
T square(T t) {
return t * t;
}
}
}
}
```
trivial expression `square(3)` won't compiled with message
`Error: none of the overloads of template main.square are
callable using argument types !()(int)`.
Why? What I missed?
More information about the Digitalmars-d
mailing list