Passing min or max as a template parameter

Some procedures perform absolutely the same steps except calling different function in some places.
For example dilation and errosion are the same except one needs to call max while another needs to call min.
The following template declarations were working fine for this purpose:
template<int op(int, int)>
global void morph(…)
{

v = op(i1, i2);

}
#define dilate morph
#define erode morph

Unfortunately nvcc 2.3 compiler gives me the following error: …kernel.cudafe1.stub.c(362) : error C2563: mismatch in formal parameter list
It is always ashame when working functionality gets broken. Any idea how to make the approach above work with cuda 2.3?

A functor approach will work:

struct Min
{
template
device
T operator()(T x, T y)
{
return min(x,y);
}
};

struct Max
{
template
device
T operator()(T x, T y)
{
return max(x,y);
}
};

template
device void morph(F op, …)
{

v = op(i1,i2);

}

global void dilate(…)
{
return morph(Max(), …);
}

global void erode(…)
{
return morph(Min(), …);
}