Local function overloading
monarch_dodra
monarchdodra at gmail.com
Sat Apr 12 10:18:01 PDT 2014
On Saturday, 12 April 2014 at 16:45:02 UTC, Philpax wrote:
> While trying to overload a function in local/function scope, I
> ran into this behaviour: http://dpaste.dzfl.pl/b4e8b9ddf78a and
> I was wondering what the cause was.
>
> As far as I can tell, this should be fine in global scope (and
> it is), but I'm curious as to why it doesn't work inside a
> function.
I *think* it has something to do with how name-mangling is done.
I don't know the details. I know you can workaround it by putting
your functions a static members of a dummy struct:
http://dpaste.dzfl.pl/268e3d2d4427
class A {}
class B {}
void main()
{
static struct Dummy
{
static void func2(A a){}
static void func2(B b){}
}
alias func2 = Dummy.func2;
A a;
func2(a);
}
More information about the Digitalmars-d-learn
mailing list