problem with template arguments deduction

Zhenya zheny at list.ru
Wed May 30 06:20:27 PDT 2012


Some time ago I decided to write in D something like boost :: 
bind.But I encountered a problem that the compiler can not deduce 
the template function. Here are a significant part of the code:

template Combination(alias indeces,U...)
{
//	static if(is(typeof(indeces) : uint[]))
//	{
		static if(indeces.length > 1)
			alias TypeTuple!(U[indeces[0]],Combination!(indeces[1..$],U)) 
Combination;
		else static if(indeces.length == 1)
			alias U[indeces[0]] Combination;
//	}
}

template bind(alias indeces)
{
//	static if(is(typeof(indeces) : uint[]))
//	{
		auto bind(R,U...)(R delegate(U) dg,Combination!(indeces,U) 
values)
		{
/*			static if(indeces.length > 1)
				return 
bind!(update!(indeces,indeces[0]))(Curry!(indeces[0])(dg,values[0]),values[1..$]);
			else static if(indeces.length == 1)
				return Curry!(indeces[0])(dg,values[0]);
*/		}
//	}
}

void main()
{
	void xyz(int x,int y,int z)
	{
		writeln("x = ",x," y = ",y," z = ",z);
	}
//	auto g = Curry!1(&xyz,cast(int)(1.1));
//	g(2,3);
	alias Combination!([0,1],int,int,int) Arg;
	Arg a;
	bind!([0,1])(&xyz,a);
	readln();
}

Please, explain to me what is wrong with this code


More information about the Digitalmars-d-learn mailing list