Re: Function Pointers with Type T

2014-09-16 Thread evilrat via Digitalmars-d-learn
On Tuesday, 16 September 2014 at 01:16:14 UTC, Adam D. Ruppe wrote: bool function(T val1,T val2) ptr=comp!T; Moreover, comp has compile time arguments, so you can't take the address of it without forwarding the arguments. So instead of comp, you use comp!T - passing the T from the outside

Re: Function Pointers with Type T

2014-09-16 Thread amparacha via Digitalmars-d-learn
Thanks Adam you saved me from alot.Just one more question how can I compare two arguments of type T. On Tuesday, 16 September 2014 at 01:16:14 UTC, Adam D. Ruppe wrote: You can get the code to compile with two changes: bool function(T)(T val1,T val2) ptr=comp; should be: bool function(T

Re: Function Pointers with Type T

2014-09-16 Thread amparacha via Digitalmars-d-learn
Thanks its the right help at right time. On Tuesday, 16 September 2014 at 09:13:38 UTC, evilrat wrote: On Tuesday, 16 September 2014 at 01:16:14 UTC, Adam D. Ruppe wrote: bool function(T val1,T val2) ptr=comp!T; Moreover, comp has compile time arguments, so you can't take the address of it

Re: Function Pointers with Type T

2014-09-16 Thread amparacha via Digitalmars-d-learn
Thankx On Tuesday, 16 September 2014 at 01:21:57 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 16 Sep 2014 01:09:27 + amparacha via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: first change: bool function(T)(T val1,T val2) ptr=comp; to auto ptr = comp!T; second

Re: Function Pointers with Type T

2014-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 16 September 2014 at 17:32:02 UTC, amparacha wrote: Thanks Adam you saved me from alot.Just one more question how can I compare two arguments of type T. If you want to compare the values, just use them like regular variables. If you want to compare the types, use: static

Function Pointers with Type T

2014-09-15 Thread amparacha via Digitalmars-d-learn
Can anyone looks at the following code to fix it.I am having error when using pointers to functions with argument of type T.This is a small portion of a program doing a generic quick sort by passing a comparison function as an argument. import std.stdio; int main(){ return 0; } bool

Re: Function Pointers with Type T

2014-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
You can get the code to compile with two changes: bool function(T)(T val1,T val2) ptr=comp; should be: bool function(T val1,T val2) ptr=comp!T; The function pointer itself isn't a template, so it doesn't need the (T) parameter. Instead, since it is inside a template, you can just use the

Re: Function Pointers with Type T

2014-09-15 Thread ketmar via Digitalmars-d-learn
On Tue, 16 Sep 2014 01:09:27 + amparacha via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: first change: bool function(T)(T val1,T val2) ptr=comp; to auto ptr = comp!T; second change: int partition(T)(T[]list,bool function(T)(T val1,T val2)ptr,int left,int right)} to