I get the feeling that this is a bad idea in C++, but before I abandon trying to make it work and go back to pointers and dereferencing (which work just fine) I though I'd ask. The idea here is to have an overloaded function taking references to various types, and here's a demonstration of it not working:
Basically, once you've defined gimmi(int &x) *and* gimmi(int x) you have to cast to get it to disambiguate; but nothing I've tried allows me to cast to match gimmi(int &x). All attempts are still considered by the compilers as ambiguous. (I've tested this on gcc 10.2, gcc 5.9.4, clang 10.0.1, MSVC 19.28, ICC 18)
Any ideas what's going on? I don't need a solution - pointers work - but I'd like to know if this can be made to as well, or am I flogging a dead horse?
Perfect, thanks! Other replies I've had elsewhere were along the lines of "but why do you want to do it". Do you, perchance, have chapter and verse on it?