Function Pointers with Type T
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 15 09:43:55 PDT 2014
amparacha:
Such questions are better asked in the D.learn newsgroup.
> 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;
bool comp(T)(T left, T right) {
// some comparison criteria
return false;
}
int partition(T)(T[] list,
bool function(T val1, T val2) f,
int left,
int right) {
return 2;
}
void sort(T)(T[] list, int left, int right) {
int spiltPoint;
bool function(T val1,T val2) ptr = ∁
spiltPoint = partition(list, ptr, left, right);
}
void main() {}
Bye,
bearophile
More information about the Digitalmars-d
mailing list