Naming methods from strings using mixin

Vladimir Panteleev vladimir at thecybershadow.net
Tue Feb 21 07:29:48 PST 2012


On Tuesday, 21 February 2012 at 14:53:06 UTC, Robert Rouse wrote:
> Using a mixin, is it possible to have it define a method based 
> on a string passed into the mixin?

A simpler way:

mixin template MakeMethod(string name)
{
	void _MakeMethod_method() { /* ... */ }
	mixin("alias _MakeMethod_method " ~ name ~ ";");
}



More information about the Digitalmars-d-learn mailing list