I have a template function, within which I need to convert a const char \* to my template value.
I know for a fact that this const char \* was originally read from a ascii text file. My current code looks like this:

```

    template <typename T>
    bool Get(T &value, std::string const &query, T const &default)
    {
        const char* result = DataHandler.GetValue(query);
        if (result != NULL)
        {
            value = static_cast<T>(result); //Here is the issue
            return true;
        }
        value = default
        return false;
    }

```

Using this with an int as example i get the error

> 
> error C2440: 'static\_cast' : cannot convert from 'const char \*' to 'int'
> 
> 
> 

Is there a way I can convert the char\* to my type T seamlessly, I could not find an answer for this on SO.

In the worst case I can make a case for the 10 types I expect and give an error if not one of these, but I would rather not do it that way if possible.