I want to write a callback like this
template<typename T>
T GetValue(T (*CallBack) (const string), string in)
{
    T value;
    try
    {
        value = CallBack(in);
    }
    catch(std::invalid_argument &e)///if no conversion could be performed
    {
        cout << "Error: invalid argument: --> " + string(e.what());
        exit(-1);
    }
    return value;
}
int main()
{
    int integer=0;
    string data;
    cin>>data;
    integer=GetValue<int>(&std::stoi, data);
    return 0;
}
but it does not works. I have the following error.
error: cannot convert "|unresolved overloaded function type|" to "int (^)(std::string)" {aka int (^)(std::__cxx11::basic_string)}
I tried other ways too. Like this:
class Object;
typedef int (Object::*CallBack)(const string&, std::size_t*, int);
Or like this:
    typedef int (std::*FCAST)(const string&);
    std::function<int(const string&)> f = (FCAST)&std::stoi;
error: address of overloaded function with no contextual type information|
But i had not success. ¿Someone knows how to do it?
Thank you so much!!
 
     
     
    