Currently I have a member function defined as such:
template<typename T> bool updateParameter(const std::string& name, const T& data);
With an overload for pointers.
template<typename T> bool updateParameter(const std::string& name, T* data);
I would like to be able to use this function as such:
int test = 20;
updateParameter<int>("name", 0);
updateParameter<int>("Referenced parameter", &test);
This way I can have a parameter object that either owns the data that it represents, or points to a user owned member.
Now the problem that I have is with the current setup MSVC implicitly will convert the const 0 of "name" to a pointer, so it ends up calling the overload designed for pointers. I can use the explicit keyword, but then I can't get the implicit conversion from const char[] to std::string for the name parameter. Is there a way of telling the compiler, MSVC and GCC that a certain field should not be implicitly converted, or at least for it to prefer the const T& version over the T* version?