Templates and function parametes

Paul D Anderson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 8 23:19:14 PDT 2014


When I try to compile these two functions, the second function is 
flagged with an already defined error:

bool testRoundTrip(T, U)(T first, U second) if (isIntegral!T && 
isFloatingPoint!U)
{
     return false;
}
bool testRoundTrip(U, T)(U first, T second) if (isIntegral!T && 
isFloatingPoint!U)
{
     return false;
}

They look to me to be distinct functions, one with an integral 
parameter followed by a floating point parameter and the other 
with a floating point parameter followed by an integral parameter.

At first I thought this was a template problem, but the following 
code also raises the same error.

bool testRoundTrip(int first, double second)
{
     return false;
}
bool testRoundTrip(double first, int second)
{
     return false;
}

What's the problem?



More information about the Digitalmars-d-learn mailing list