On 01.06.2012 16:47, Zhenya wrote:
On Friday, 1 June 2012 at 12:38:11 UTC, Dmitry Olshansky wrote:
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(alias dg, V...)(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.
Error 1 basic type expected, not alias c:\users\zhenya\documents\visual
studio 2010\Projects\D\ConsoleApp1\ConsoleApp1\main.d 75
Похоже что alias не может быть аргументом времени выполнения



ну как же map, filter и тд работают )
ну передавай свой delegate как параметр времени компиляции через !(...)
все будет ок ...

auto bind(alias dg, V...)(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])
 (values[0]),values[1..$]);

>> else
>> assert(0);
>> }
>> }

--
Dmitry Olshansky

Reply via email to