You can't partially specialize template function, but you can for template class. So you can forward your implementation to a dedicated class. Following may help: (https://ideone.com/2V39Ik)
namespace details
{
template <typename T>
struct f_caller
{
static void f() { std::cout << "generic" << std::endl; }
};
template<>
struct f_caller<std::string>
{
static void f() { std::cout << "string" << std::endl; }
};
template<typename T>
struct f_caller<std::vector<T>>
{
static void f() { std::cout << "vector" << std::endl; }
};
}
template<typename T>
void f()
{
details::f_caller<T>::f();
}