The function templates:
Code:
template<typename Contain1, typename Contain2,
typename BinaryFunc>
void testBinary(Contain1& src1, Contain1& src2,
Contain2& dest, BinaryFunc f) {
transform(src1.begin(), src1.end(), src2.begin(), dest.begin(), f);
}
template<typename Contain1, typename Contain2>
void testBinary(Contain1& src1, Contain2& src2,
Contain2& dest, modulus<float> f) {
Contain1::iterator iter = src1.begin();
Contain2::iterator iter2 = dest.begin();
while (iter++ != src1.end())
*iter2++ = 0;
}
The function call "testBinary(x, y, r, modulus<float>())" is rejected by the compiler for being ambigious. I thought that the compiler uses the more specialized overloaded form, which should be the 2nd one. Does someone have an idea, how I could convince the compiler to see it my way?
Or am I wrong about the "compiler uses the more specialized version of overloaded function templates"?
TIA