template should be declared like this in David Rodríguez's method (for functions with return type):
template <class<template T, typename std::enable_if<!std::is_same<T,std::string>::value>::type* = nullptr > T func(T x){} For multiple condition:
template <class<template T, typename std::enable_if<!std::is_same<T,std::string>::value &&!std::is_same<T,int>::value>::type* = nullptr > T func(T x){} For functions without return type:
template <class<template T> typename std::enable_if<!std::is_same<T,std::string>::value>::type func(T x){} For multiple condition:
template <class<template T> typename std::enable_if<!std::is_same<T,std::string>::value &&!std::is_same<T,int>::value>::type func(T x){} Don't forget to include #include <type_traits>