On 2012-06-16 03:18, Andrej Mitrovic wrote:

Of course there is, this is D not Java! Enjoy:

import std.stdio;
import std.metastrings;

void fooBar(T : Foo)(int x) { writeln(x); }

struct Foo
{
     static auto opDispatch(string name, Params...)(Params params)
     {
         enum strOf = typeof(this).stringof;
         enum str = Format!("return .%s!%s(params);", name, strOf);
         mixin(str);
     }
}

void main()
{
     Foo.fooBar(4);
}

That's cheating :)

--
/Jacob Carlborg

Reply via email to