"static" UFCS
Jacob Carlborg
doob at me.com
Sat Jun 16 06:35:51 PDT 2012
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
More information about the Digitalmars-d
mailing list