Q:

Templates: Get type and map to function

I currently have a series of C++ functions that each call to a C function located elsewhere, these functions essentially do the same thing but return different types. I would like to be able to dynamically get the type of a template and call the associated function, something like
template<typename T>
T getVal(const char* id) {
    return funcMap[T.someIdentifyingMethod](id);
}

Is this possible and if so how would I go about it?

A:

It sounds like you just want template specialisation:
template<typename T>
struct wrapper;

template<>
struct wrapper<int>
{
    static int getVal(char const* id) { /* ... */ }
};

template<>
struct wrapper<widget>
{
    static widget getVal(char const* id) { /* ... */ }
};

Then you would call wrapper<T>::getVal(id).

