opPropDispatch

sclytrack sclytrack at ars.com
Sun Apr 22 13:11:50 PDT 2012



struct Dispatcher
{
	@property
	void opDispatch(string name)(string val)
	{
		writeln(val);
	}
	
	@property
	string opDispatch(string name)()
	{
		return "getter";
	}
	
	void opDispatch(string name)()
	{
		writeln(name);
	}
}


I can't seem to make a "dispatcher" that supports both the normal method 
syntax and the property syntax simultaneously. Is this going to change 
in the future?

And if so, how will this be done?

Like this?

struct Dispatcher
{
	@property
	void opPropDispatch(string name)(string val)
	{
		writeln(val);
	}
	
	@property
	string opPropDispatch(string name)()
	{
		return "getter";
	}
	
	void opDispatch(string name)()
	{
		writeln(name);
	}
}

I've got absolutely no clue.



More information about the Digitalmars-d-learn mailing list