Suppose I define some function f with the following 3 signatures in C++:
void f(int x) {}
void f(int& x) {}
void f(const int& x) {}
These functions can coexist since they differ in the types of the arguments.
Now I run the following code:
int main {
   int i = 3;
   const int ci = 4;
   f(3);
   f(i);
   f(ci);
}
How does C++ know which overloaded function to call in this specific case ? What are rules in general ( best practice ? ) for writing overloaded functions in C++ as to avoid ambiguity. Does the current C++14 standard specify any specific rules ?