I have a problem with creating a template in c++. I am using xcode for mac.
When passing an int to a swap function I get the error code "ambiguous call". However, passing strings works fine. Why is that?
This is my code
#include <iostream>
#include <cmath>
using namespace std;
template <typename T>
void swap(T& c, T& d)
{
    T temp = c;
    c = d;
    d = temp;
}
int main()
{
    int a = 10;
    int b = 20;
    swap(a, b);                   // this is an error "ambiguous call"
    cout << a << "\t" << b;
    string first_name = "Bob";
    string last_name = "Hoskins";
    swap(first_name, last_name);  // this works
    cout << first_name << "\t" << last_name;
    return 0;
}
 
    