I'm new in using templates in C++, I want to do different things depending on type used between < and >, so function<int>() and function<char>() won't do the same things.
How can I achieve this?
template<typename T> T* function()
{
    if(/*T is int*/)
    {
        //...
    }
    if(/*T is char*/)
    {
        //...
    }
    return 0;
}
                You want to use explicit specialization of your function template:
template<class T> T* function() {
};
template<> int* function<int>() {
    // your int* function code here
};
template<> char* function<char>() {
    // your char* function code here
};
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With