does alias this work correctly?

Andrey andr-sar at yandex.ru
Sun Jan 13 15:21:18 PST 2013


> I just want very much avoid renaming function,it's principle 
> for me.
> So I would like to know is my sample right or no.

I think that the main overall principle here is that is it 
impossible to have two functions which differ only by static 
attribute. I even do not imagine the use case of this.

Well, here is the most natural way to achieve similar effect, I 
suppose:

struct MyStruct {

	struct Static {

		static void myfun() {
			writeln("static myfun");
		}
	}

	void myfun() {
		writeln("myfun");
	}

	static Static opCall() {
		return Static();
	}
}


MyStruct obj;

obj.myfun(); //dynamic;
MyStruct().myfun(); //static;


More information about the Digitalmars-d-learn mailing list