problem with template arguments deduction
Dmitry Olshansky
dmitry.olsh at gmail.com
Fri Jun 1 05:38:01 PDT 2012
On 01.06.2012 15:47, Zhenya wrote:
> Error 3 Error: function expected before (), not bind(&checker,2,1,4) of
> type _error_ c:\users\zhenya\documents\visual studio
> 2010\Projects\D\ConsoleApp1\ConsoleApp1\main.d 98
>
> Error 1 Error: template instance bind!([0,2]) bind!([0,2]) does not
> match template declaration bind(D,V...) c:\users\zhenya\documents\visual
> studio 2010\Projects\D\ConsoleApp1\ConsoleApp1\main.d 81
>
> Error 2 Error: template instance main.bind!([1,0,3]).bind!(void
> delegate(int _param_0, int _param_1, int _param_2, int _param_3)
> @system,int,int,int) error instantiating
> c:\users\zhenya\documents\visual studio
> 2010\Projects\D\ConsoleApp1\ConsoleApp1\main.d 98
>
>
It may have some problem with matching this delegate hmmm.
What if you try this:
template Bind(alias indeces)
if(is(typeof(indeces) : int[]))
{
auto bind(V...)(alias dg,V values)
if(is(V == Combination!(indeces,ParameterTypeTuple!D)))
{
static if(indeces.length > 1)
return
Bind!(update!(indeces,indeces[0])[1..$]).bind(Curry! (indeces[0])
(dg,values[0]),values[1..$]);
else
assert(0);
}
}
alias instead of delegate - it's just more powerful
I relaxed constraints and static ifs ---> proper template constraints.
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list