I have 2 basic functions differ about type of parameter but code in these most of the same. Because i do not want to repeat code so i do:
bool func(std::string x)
{
if(x=="true")
return true;
return false;
}
bool func(int x)
{
if(x!=-1)
return true;
return false;
}
bool fun( auto x,bool (*f)(auto ))
{
return (*f)(x);
};
I have used auto keyword to be compatible with both functions, but it has something wrong so I need your supports.
if (x) return true; return false;can always be replaced withreturn (x);bool