KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If you overload a function and then call it with an argument that perfectly matches one of the overloads int f(int){return 3;} int f(bool){return 4;} ... //inside main() f(1); //Calls f(int) the compiler simply chooses this (perfect) match before attempting any implicit conversions. However I've been trying to overload a function tempĺate as in template <bool veracity> int f(){return 1;} template <int amount> int f(){return 2;} ... //inside main() f<1>(); but the compiler keeps complainning about ambiguous call to the overloaded f(), stating it could be either f<true>() or f<1>() . Shouldn't the compiler just choose the perfect match, instead of trying to convert 1 to true ? I was under the impression that implicit conversion for template arguments was actually more restrictive than implicit conversion of function arguments. Is there a way to get around this problem?
Tags (comma-separated)
Save Edits
Cancel