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 if(is(T
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
wrote:
first change:
bool function(T)(T val1,T val2) ptr=∁
to
auto ptr = &comp!T;
second change:
int partition(T)(T[]list,bo
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
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=∁
should be:
bool function(T val1,T val
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
On Tue, 16 Sep 2014 01:09:27 +
amparacha via Digitalmars-d-learn
wrote:
first change:
bool function(T)(T val1,T val2) ptr=∁
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
int partition(T)(T[]list,bool functio
You can get the code to compile with two changes:
bool function(T)(T val1,T val2) ptr=∁
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 T fr
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 comp(T)(T