CloneFunction

A template mixin which allow you to clone a function, and specify the implementation.

mixin template CloneFunction (
alias Func
string body_
string identifier = __traits(identifier, Func)
) {}

Examples

interface ITest
{
  int foo(string par, int, string p = "foo", int = 10) pure @safe nothrow const;
  @property int foo2() pure @safe nothrow const;
}

class Test : ITest
{
	mixin CloneFunction!(ITest.foo, q{
		return 84;
	}, "customname");
override:
	mixin CloneFunction!(ITest.foo, q{
		return 42;
	});
	mixin CloneFunction!(ITest.foo2, q{
		return 42;
	});
}

assert(new Test().foo("", 21) == 42);
assert(new Test().foo2 == 42);
assert(new Test().customname("", 21) == 84);

Meta