On Thursday, 7 July 2022 at 15:19:59 UTC, Alexandru Ermicioi wrote:
>On Thursday, 7 July 2022 at 13:59:17 UTC, 12345swordy wrote:
>Side note: Does D really needs function overloading? You can achieve the same effect by using meta-programming.
- Alex
Just wondering, how do you achieve it using meta-programming?
For non-virtual functions, just use a template function:
auto f(T)(T v)
{
static if (is(T : int))
// insert code for f(int) overload
else
...
}
It doesn't work for virtual functions as they can't be templates.